Checks if user is authenticated and calls GET_AUTH or performs logout.
        Otherwise, returns the login template.
2980
def GET(self, *args, **kwargs):
        
        if self.user_manager.session_logged_in():
            if not self.user_manager.session_username() and not self.__class__.__name__ == "ProfilePage":
                raise web.seeother("/preferences/profile")

            if not self.is_lti_page and self.user_manager.session_lti_info() is not None: #lti session
                self.user_manager.disconnect_user()
                return self.template_helper.get_renderer().auth(self.user_manager.get_auth_methods(), False)

            return self.GET_AUTH(*args, **kwargs)
        else:
            return self.template_helper.get_renderer().auth(self.user_manager.get_auth_methods(), False)
906020
def LogoutSessionId(self):
        
        if self.__SenseApiCall__('/logout.json', 'POST'):
            self.__setAuthenticationMethod__('not_authenticated')
            return True
        else:
            self.__error__ = "api call unsuccessful"
            return False
388053
def login(self, template='login'):
        '''
        
        '''
        def _login(env, data):
            form = self._login_form(env)
            next = env.request.GET.get('next', '/')
            login_failed = False
            if env.request.method == 'POST':
                if form.accept(env.request.POST):
                    user_identity = self.get_user_identity(
                                                env, **form.python_data)
                    if user_identity is not None:
                        response = HTTPSeeOther(location=next)
                        return self.login_identity(user_identity, response)
                    login_failed = True
            data.form = form
            data.login_failed = login_failed
            data.login_url = env.root.login.as_url.qs_set(next=next)
            return env.template.render_to_response(template, data.as_dict())
        return web.match('/login', 'login') | _login
188330
def check_basic_auth(self, username, password):
        
        valid = self.users.check_password(
            username, password
        )
        if not valid:
            log.warning('Invalid login from %s', username)
            valid = False
        return (
            valid,
            username
        )
839188
def is_auth(self):
        
        if self.user_id is None:
            self.user_id = self.session.get('user_id')
        return bool(self.user_id)
161839
public static function is_loggedin() {
	if (self::is_active() == false) {
		return false;
	}
	if (self::get_user_id() == false) {
		return false;
	}
	
	return true;
}
310995
def authenticate
      if username? and password?
        user = user_model.find_for_session(username)

        if user
          if user.valid_session?
            if user.authenticate(@password)
              return user
            end
          end

          user.failed_authentication!
          user = nil
        end
      end

      nil
    end
295300
def login():
    
    req = flask.request.get_json(force=True)
    username = req.get('username', None)
    password = req.get('password', None)
    user = guard.authenticate(username, password)
    ret = {'access_token': guard.encode_jwt_token(user)}
    return (flask.jsonify(ret), 200)
463049
def authenticated(function):
    """"""
    def wrapped(*args):
        """Wrap function."""
        try:
            return function(*args)
        except USPSError:
            _LOGGER.info("attempted to access page before login")
            _login(args[0])
            return function(*args)
    return wrapped
195364
def _verify_authentication(self, handler, args, kwargs):
        
        if not self.user_manager.session_logged_in():
            raise APIForbidden()
        return handler(*args, **kwargs)
1211917
def is_authenticated(self):
        '''
        
        '''
        session_token = self.get_session_token()
        if not session_token:
            return False
        try:
            response = client.get('/users/me', params={'session_token': session_token})
        except LeanCloudError as e:
            if e.code == 211:
                return False
            else:
                raise
        return response.status_code == 200
121013
def watch_login(func):
    
    @wraps(func)
    def decorated_login(request, *args, **kwargs):

        response = func(request, *args, **kwargs)

        lockout = AccessAttempt(request, response)
        user_access = lockout.check_failed_login()

        if user_access.is_locked or lockout.is_ip_banned:
            return lockout.get_lockout_response()

        return response

    return decorated_login
43341
def perform_authentication(self):
        

        if not self.authenticators:
            return

        request.user = None
        request.auth = None

        for authenticator in self.authenticators:
            auth_tuple = authenticator.authenticate()

            if auth_tuple:
                request.user = auth_tuple[0]
                request.auth = auth_tuple[1]
                break
811008
def superuser_required(view_func=None, redirect_field_name=REDIRECT_FIELD_NAME,
                       login_url='admin:login'):
    
    actual_decorator = user_passes_test(
        lambda u: u.is_active and u.is_superuser,
        login_url=login_url,
        redirect_field_name=redirect_field_name
    )
    if view_func:
        return actual_decorator(view_func)
    return actual_decorator
14874
def require_auth(view_func):
    
    from horizon.exceptions import NotAuthenticated

    @functools.wraps(view_func, assigned=available_attrs(view_func))
    def dec(request, *args, **kwargs):
        if request.user.is_authenticated:
            return view_func(request, *args, **kwargs)
        raise NotAuthenticated(_("Please log in to continue."))
    return dec
255778
def r_oauth_logout(self):
        
        session.pop('oauth_user_uri', None)
        session.pop('oauth_user_name', None)
        next = request.args.get('next','')
        if next is not None:
            return redirect(session['next'])
        else:
            return {
                "template": "main::index.html"
            }
384972
def basic_auth_required(view_func):
    
    @wraps(view_func)
    def wrapper(*args, **kwargs):
        if app.config.get('BASIC_AUTH_ACTIVE', False):
            if basic_auth.authenticate():
                return view_func(*args, **kwargs)
            else:
                return basic_auth.challenge()
        else:
            return view_func(*args, **kwargs)
    return wrapper