Call after login decorator.
163326
def check_read_httpauth_access(func):
    

    def wrapper(request, *args, **kwargs):
        database_name = kwargs.get('database_name', "")
        collection_name = kwargs.get('collection_name', "")
        if not database_name or not collection_name:
            return HttpResponse(unauthorized_json_response(),
                                content_type="application/json")

        try:
            # Check to see if we have a matching record in DB access.
            dac = HTTPAuthReadAPI.objects.get(
                database_name=database_name, collection_name=collection_name)
        except HTTPAuthReadAPI.DoesNotExist:
            return HttpResponse(unauthorized_json_response(),
                                content_type="application/json")

        dac_groups = dac.groups.all()
        user_groups = request.user.groups.all()

       # allowedgroups
        in_group = False
        group = None
        for dg in dac_groups:
            if dg in user_groups:
                in_group = True
                group = dg

        if not in_group:
            message = "NOT-IN-GROUP: You do not have access to this collection. Please see your system administrator."

            body = {"code": 400,
                    "message": message,
                    "errors": [message, ]}
            return HttpResponse(json.dumps(body, indent=4, ),
                                content_type="application/json")

        # If search keys have been limitied...
        if dac.search_keys:
            search_key_list = shlex.split(dac.search_keys)
            keys = []
            for k in request.GET.keys():

                if k not in search_key_list:
                    message = "Search key %s  is not allowed." % (k)

                    body = {"code": 400,
                            "message": k,
                            "errors": [message, ]}

                    return HttpResponse(json.dumps(body, indent=4, ),
                                        content_type="application/json")

        return func(request, *args, **kwargs)

    return update_wrapper(wrapper, func)
749859
def special_login_handler(self, delay_factor=1):
        """"""
        delay_factor = self.select_delay_factor(delay_factor)
        self.write_channel(self.RETURN)
        time.sleep(1 * delay_factor)
503100
def login_required(view):
    """"""

    @functools.wraps(view)
    def wrapped_view(**kwargs):
        if g.user is None:
            return redirect(url_for("auth.login"))

        return view(**kwargs)

    return wrapped_view
1162922
private void login(final String oldToken) {
		tokenRequestHandler.login(new TokenChangedHandler() {

			public void onTokenChanged(TokenChangedEvent event) {
				setToken(event.getToken(), event.getUserDetail(), false);
				List<RetryCommand> retryCommands = afterLoginCommands.remove(oldToken);
				if (null != retryCommands) {
					for (RetryCommand retryCommand : retryCommands) {
						execute(retryCommand.getCommand(), retryCommand.getDeferred());
					}
				}
			}
		});
	}
560563
public function afterLogin()
    {
        $this->last_login = $this->freshTimestamp();

        if ($this->trashed()) {
            $this->restore();

            Mail::sendTo($this, 'rainlab.user::mail.reactivate', [
                'name' => $this->name
            ]);

            Event::fire('rainlab.user.reactivate', [$this]);
        }
        else {
            parent::afterLogin();
        }

        Event::fire('rainlab.user.login', [$this]);
    }
292575
def login(container):
    """"""
    columns, lines = shutil.get_terminal_size()  # Temporary
    try:
        subprocess.check_call([
            "docker", "exec",
            "--env", f"COLUMNS={str(columns)},LINES={str(lines)}",  # Temporary
            "--env", f"LINES={str(lines)}",  # Temporary
            "--interactive",
            "--tty",
            container,
            "bash",
            "--login"
        ])
    except subprocess.CalledProcessError:
        raise RuntimeError() from None
125859
def login_required(function=None, message=None, login_url=None):
    
    actual_decorator = user_passes_test(
        lambda u: u.is_authenticated(),
        message=message,
        login_url=login_url
    )

    if function:
        return actual_decorator(function)
    return actual_decorator
852338
def login_required(function=None, username=None, basic=False, must=None):
    

    if function and not callable(function):
        raise ValueError(
            'Decorator receives only named arguments, '
            'try login_required(username="foo")'
        )

    def check(validators):
        """Return in the first validation error, else return None"""
        if validators is None:
            return
        if not isinstance(validators, (list, tuple)):
            validators = [validators]
        for validator in validators:
            error = validator(get_username())
            if error is not None:
                return SimpleLogin.get_message('auth_error', error), 403

    def dispatch(fun, *args, **kwargs):
        if basic and request.is_json:
            return dispatch_basic_auth(fun, *args, **kwargs)

        if is_logged_in(username=username):
            return check(must) or fun(*args, **kwargs)
        elif is_logged_in():
            return SimpleLogin.get_message('access_denied'), 403
        else:
            flash(SimpleLogin.get_message('login_required'), 'warning')
            return redirect(url_for('simplelogin.login', next=request.path))

    def dispatch_basic_auth(fun, *args, **kwargs):
        simplelogin = current_app.extensions['simplelogin']
        auth_response = simplelogin.basic_auth()
        if auth_response is True:
            return check(must) or fun(*args, **kwargs)
        else:
            return auth_response

    if function:
        @wraps(function)
        def simple_decorator(*args, **kwargs):
            """This is for when decorator is @login_required"""
            return dispatch(function, *args, **kwargs)
        return simple_decorator

    def decorator(f):
        """This is for when decorator is @login_required(...)"""
        @wraps(f)
        def wrap(*args, **kwargs):
            return dispatch(f, *args, **kwargs)
        return wrap
    return decorator
62115
def login_handler(response, provider, query):
    """"""

    connection = _datastore.find_connection(**query)

    if connection:
        after_this_request(_commit)
        token_pair = get_token_pair_from_oauth_response(provider, response)
        if (token_pair['access_token'] != connection.access_token or
            token_pair['secret'] != connection.secret):
            connection.access_token = token_pair['access_token']
            connection.secret = token_pair['secret']
            _datastore.put(connection)
        user = connection.user
        login_user(user)
        key = _social.post_oauth_login_session_key
        redirect_url = session.pop(key, get_post_login_redirect())

        login_completed.send(current_app._get_current_object(),
                             provider=provider, user=user)

        return redirect(redirect_url)

    login_failed.send(current_app._get_current_object(),
                      provider=provider,
                      oauth_response=response)

    next = get_url(_security.login_manager.login_view)
    msg = '%s account not associated with an existing user' % provider.name
    do_flash(msg, 'error')
    return redirect(next)
498914
def required(self, fn):
        """"""
        @functools.wraps(fn)
        def decorated(*args, **kwargs):
            if (not self._check_auth()
               # Don't try to force authentication if the request is part
               # of the authentication process - otherwise we end up in a
               # loop.
               and request.blueprint != self.blueprint.name):
                return redirect(url_for("%s.login" % self.blueprint.name,
                                        next=request.url))
            return fn(*args, **kwargs)
        return decorated
497005
def _login(self, environ, start_response):
        """"""
        response = HTTPUnauthorized()
        response.www_authenticate = ('Basic', {'realm': self._realm})
        return response(environ, start_response)
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
24091
def after_initial_login(self, response):
        
        if LOGIN_FAILURE_MSG in response.text:
            self.logger.error(
                "Credentials failed. Either add/update the current credentials "
                "or remove them to enable auto auth"
            )
            return

        self.logger.info("successfully completed initial login")

        if self.single_url:
            yield scrapy.Request(
                self.single_url,
                callback=self.parse_item,
                errback=self.handle_error
            )
        else:
            for url in self.start_urls:
                yield scrapy.Request(
                    url,
                    callback=self.analyze_url_list,
                    errback=self.handle_error
                )
1188293
public function afterLogin()
    {
        $returnUrl = Yii::$app->user->returnUrl;
        $returnUrlParts = explode('/', is_array($returnUrl) ? reset($returnUrl) : $returnUrl);
        $url = end($returnUrlParts) == 'index.php' ? '/' : Yii::$app->user->returnUrl;

        return $this->redirect($url);
    }
1046964
@Override
    protected void after() {
        super.after();
        if (adminSession != null) {
            LOG.info("Logging off {}", adminSession.getUserID());
            adminSession.logout();
            adminSession = null;
        }
        if (anonSession != null) {
            LOG.info("Logging off {}", anonSession.getUserID());
            anonSession.logout();
            anonSession = null;
        }
        for (final Session session : userSessions.values()) {
            LOG.info("Logging off {}", session.getUserID());
            session.logout();
        }
        userSessions.clear();
        LOG.info("Closed all sessions");
    }
541755
async def login(self, request, id_):
        """"""
        session = await self.load(request)
        session['id'] = id_
753399
def after(self, context):
        ""
        self._invoke(self._after, context)
        run.after_each.execute(context)