/** * Logout the active user. * * @param UserAuthenticator $authenticator * @param Guard $auth * @return \Illuminate\Http\RedirectResponse */ public function logout(UserAuthenticator $authenticator, Guard $auth) { if (!$auth->guest()) { $authenticator->logout(); } $this->messages->success($this->request->get('message', 'anomaly.module.users::message.logged_out')); return $this->response->redirectTo($this->request->get('redirect', '/')); }
/** * Handle the form. * * @param LoginFormBuilder $builder * @param UserAuthenticator $authenticator * @param Redirector $redirect */ public function handle(LoginFormBuilder $builder, UserAuthenticator $authenticator, Redirector $redirect) { if (!($user = $builder->getUser())) { return; } $authenticator->login($user, $builder->getFormValue('remember_me')); $builder->setFormResponse($redirect->intended($builder->getFormOption('redirect', '/'))); }
/** * Log the user out. * * @param UserAuthenticator $authenticator * @param Guard $auth * @return \Illuminate\Http\RedirectResponse|Redirector */ public function logout(UserAuthenticator $authenticator, Guard $auth) { if (!$auth->guest()) { $authenticator->logout(); } $this->messages->success('anomaly.module.users::message.logged_out'); return redirect('admin/login'); }
/** * Handle the form. * * @param LoginFormBuilder $builder * @param UserAuthenticator $authenticator * @param UserSecurity $security * @param Redirector $redirect */ public function handle(LoginFormBuilder $builder, UserAuthenticator $authenticator, UserSecurity $security, Redirector $redirect) { if (!($user = $builder->getUser())) { return; } $response = $security->check($user); if ($response instanceof Response) { $authenticator->logout($user); $builder->setFormResponse($response); return; } $authenticator->login($user, $builder->getFormValue('remember_me')); $builder->setFormResponse($redirect->intended($builder->getFormOption('redirect', '/'))); }
/** * @param UserAuthenticator $authenticator * @param MessageBag $message * @param Redirector $redirect * @return bool|\Illuminate\Http\RedirectResponse */ public function handle(UserAuthenticator $authenticator, MessageBag $message, Redirector $redirect) { if (!$this->user->isActivated()) { $message->error('Your account has not been activated.'); $authenticator->logout(); // Just in case. return $redirect->back(); } if (!$this->user->isEnabled()) { $message->error('Your account has been disabled.'); $authenticator->logout(); // Just in case. return $redirect->back(); } return true; }
/** * Handle the command. * * @param Repository $cache * @param Request $request * @param UserAuthenticator $authenticator * @param SettingRepositoryInterface $settings * @param ThrottleSecurityCheckExtension $extension * @return bool */ public function handle(Repository $cache, Request $request, UserAuthenticator $authenticator, SettingRepositoryInterface $settings, ThrottleSecurityCheckExtension $extension) { $maxAttempts = $settings->value('anomaly.extension.throttle_security_check::max_attempts', 5); $lockoutInterval = $settings->value('anomaly.extension.throttle_security_check::lockout_interval', 1); $throttleInterval = $settings->value('anomaly.extension.throttle_security_check::throttle_interval', 1); $attempts = $cache->get($extension->getNamespace('attempts:' . $request->ip()), 1); $expiration = $cache->get($extension->getNamespace('expiration:' . $request->ip())); if ($expiration || $attempts >= $maxAttempts) { $cache->put($extension->getNamespace('attempts:' . $request->ip()), $attempts + 1, $throttleInterval); $cache->put($extension->getNamespace('expiration:' . $request->ip()), time(), $lockoutInterval); $authenticator->logout(); // Just for safe measure. return $this->dispatch(new MakeResponse()); } $cache->put($extension->getNamespace('attempts:' . $request->ip()), $attempts + 1, $throttleInterval); return true; }