Handle a login request.

@param Request $request

@return mixed
335648
public function postLogin(Request $request)
    {
        $this->loginValidator($request->all())->validate();

        $credentials = $request->only([$this->username(), 'password']);
        $remember = $request->get('remember', false);

        if ($this->guard()->attempt($credentials, $remember)) {
            return $this->sendLoginResponse($request);
        }

        return back()->withInput()->withErrors([
            $this->username() => $this->getFailedLoginMessage(),
        ]);
    }
889255
public function authentication(Request $request)
    {
        try {
            $this->authRepositoryInterface->authenticate($request->all());
        } catch (FormValidationException $e) {
            Flash::error($e->getMessage());

            return redirect()
              ->route('auth.login')
              ->withErrors($e->getErrors());
        } catch (AuthenticationException $e) {
            Flash::error($e->getMessage());

            return redirect()->route('auth.login');
        }

        return redirect()->route('dashboard.index');
    }
985790
protected function authenticateRequest(Request $request)
    {
        if ($this->authenticator && $this->authenticate) {
            return $this->authenticator->authenticate($request);
        }

        return $request;
    }
603784
public function postLogout (Request $request)
    {
        if ($redirect = $request->getSession ()->get ('post-login-redirect'))
        {
            $request->getSession ()->set ('post-login-redirect', null);
            $request->getSession ()->set ('cancel-login-redirect', null);

            return Response::redirect ($redirect);
        }

        return Response::redirect (URLBuilder::getURL ('/'));
    }
1266171
public function getAuthenticatedUser(Request $request)
    {
        if (!$this->checkForUserIdWithinSession($request)) {
            $this->logger->info('security.authentication.form: not authenticated');

            return null;
        }

        $id = $this->getUserIdFromSession($request);

        if (null === $user = $this->find($id)) {
            $this->logger->warning('security.authentication.form: user with id {id} is not resolvable', ['id' => $id]);
            $this->session->remove($request, self::USER_KEY);

            return null;
        }

        $this->logger->info('security.authentication.form: authenticated user with id {id}', ['id' => $id]);

        return $user;
    }
652831
public function resetPassword(Request $request)
    {
        $event = new AccessControlEvent($request);
        $this->password()->resetPasswordConfirm($request->get('token'), $request->getClientIp(), $event);

        return $this->redirectToRoute('login', ['action' => 'login']);
    }
721789
private function sendLoginResponse(Request $request)
    {
        $user = user();

        // notify message
        if ($user->getAttribute('logged_in_at')) {
            notify()->info('Info',
                'Last time you logged in was ' . $user->logged_in_at->diffForHumans(),
                'clock-o rotateIn animated', 8000);
        }
        else {
            notify()->info('Welcome',
                'Hi ' . $user->fullname . '. Welcome to ' . config('app.name'),
                'bell swing animated', 8000);
        }

        // log
        $this->logLogin($request, 'success');

        // update logged_in_at
        $user->update(['logged_in_at' => Carbon::now()]);

        $request->session()->regenerate();

        $this->clearLoginAttempts($request);

        log_activity('Login', $user->fullname . ' logged in.');

        // if admin - go to admin - else website
        $url = $user->hasRole('admin') ? "/admin" : "/";

        // if ajax (can be from a login modal)
        if (request()->ajax()) {
            return json_response(['redirect' => config('app.url') . $url]);
        }

        return redirect()->intended($url);
    }
1339907
protected function handleRequest(Request $request)
    {
        if ($this->isLaravel()) {
            return $this->getKernel()->handle($request);
        }

        return $this->getApplication()->dispatch($request);
    }
846472
public function handle($request)
    {
        $this->loadAuthManager();
        
        try {
            $response = $this->sendRequestThroughRouter($request);
            $response = $response->getContent();
            
            $json = json_decode($response, true);
            if (json_last_error() == JSON_ERROR_NONE) {
                $response = $json;
            }
        } catch (Exception $e) {
            if ($e instanceof NotFoundHttpException) {
                $response = $e;
            } else {
                throw $e;
            }
        }
        
        $this->app['events']->fire('wskernel.handled', [$request, $response]);
        
        return $response;
    }
1134705
public function handle(Request $request)
	{
		$response = $this->next($request);

		// If CLI then we have to gather all query, post and header values
		// into params for Oauth_Provider's constructor.
		$params = array();

		if ($this->app->runningInConsole())
		{
			$queryvars = $this->app['request']->get('queryvars');
			$postvars  = $this->app['request']->get('postdata');

			if (!empty($queryvars))
			{
				foreach ($queryvars as $key => $value)
				{
					if (isset($queryvars[$key]))
					{
						$params[$key] = $queryvars[$key];
					}
					else if (isset($postvars[$key]))
					{
						$params[$key] = $postvars[$key];
					}
				}
			}

			if (!empty($postvars))
			{
				foreach ($postvars as $key => $value)
				{
					if (isset($queryvars[$key]))
					{
						$params[$key] = $queryvars[$key];
					}
					else if (isset($postvars[$key]))
					{
						$params[$key] = $postvars[$key];
					}
				}
			}

			if (empty($params))
			{
				return false;
			}
		}

		$this->app['authn'] = $this->app['auth']->authenticate($params);

		$this->app['request']->setVar('validApiKey', !empty($this->app['authn']['consumer_key']));

		return $response;
	}
628289
public function postLogin(Request $request)
    {
        $credentials = $request->only(['mobile', 'password']);

        $validator = Validator::make($credentials, [
            'mobile' => 'required', 'password' => 'required',
        ]);

        if ($validator->fails()) {
            return Redirect::back()->withInput()->withErrors($validator);
        }

        if (Auth::guard('merchant')->attempt($credentials)) {
            merchant_toastr(trans('merchant.login_successful'));

            return redirect()->intended(config('merchant.route.prefix'));
        }

        return Redirect::back()->withInput()->withErrors(['mobile' => $this->getFailedLoginMessage()]);
    }
710264
protected function getPassword(Request $request)
    {
        $url = $request->getQueryParam('url');

        $password = $request->getParam('password');
        if (isset($password)) {
            $this->sessionSegment->setFlash($url, $password);
        } else {
            $password = $this->sessionSegment->getFlash($url);
        }

        return $password;
    }
846650
protected function _cookieLogin(Request $request)
    {
        $controller = $this->_registry->getController();
        if (empty($controller->Cookie)) {
            $controller->loadComponent('Cookie');
        }

        $cookie = $controller->Cookie->read('User.Cookie');
        if ($cookie) {
            $cookie = json_decode($cookie, true);
            if (isset($cookie['user']) &&
                isset($cookie['hash']) &&
                $cookie['hash'] == Security::hash($cookie['user'], 'sha1', true)
            ) {
                $cookie['user'] = json_decode($cookie['user'], true);
                $user = $this->_findUser($cookie['user']['username']);
                if (!empty($user) && is_array($user)) {
                    if (isset($user['password'])) {
                        unset($user['password']);
                    }
                    $controller->Auth->setUser($user);

                    return true;
                }
            }
        }

        $cacheKey = 'permissions_anonymous';
        $permissions = Cache::read($cacheKey, 'permissions');
        $action = $this->action($request);

        if ($permissions === false) {
            $permissions = $this->_rolePermissions(ROLE_ID_ANONYMOUS);
            Cache::write($cacheKey, $permissions, 'permissions');
        }

        if (isset($permissions[$action])) {
            return true;
        }

        return false;
    }
264037
public function handle(Request $request)
    {
        $pathInfo = $request->getPathInfo();

        if (0 === strpos($pathInfo, $this->basePath)) {
            foreach ($this->routes as $config) {
                list($method, $pattern, $controller) = $config;

                if ($request->getMethod() === strtoupper($method)
                    && preg_match('!^' . preg_quote($this->basePath . $pattern, '!') . '$!', $request->getPathInfo())
                ) {
                    return call_user_func($controller, $request);
                }
            }
        }

        return null;
    }
1074079
public function authenticate(Request $request)
    {
        $email    = $request->input(self::AUTH_PARAM_EMAIL, null);
        $password = $request->input(self::AUTH_PARAM_PASSWORD, null);

        if ($email !== null &&
            $password !== null &&
            ($user = User::query()->where(User::FIELD_EMAIL, '=', strtolower($email))->first()) !== null
        ) {
            /** @var HasherInterface $hasher */
            $hasher = app(HasherInterface::class);
            if ($hasher->check($password, $user->{User::FIELD_PASSWORD_HASH}) === true) {
                /** @var TokenCodecInterface $codec */
                $codec = app(TokenCodecInterface::class);
                $token = $codec->encode($user);

                $this->getLogger()->debug(
                    'Account login success.',
                    [User::FIELD_EMAIL => $email, User::FIELD_ID => $user->getKey()]
                );

                return response($token);
            }
        }

        $this->getLogger()->debug('Account login failed.', [User::FIELD_EMAIL => $email]);

        return response(null, Response::HTTP_UNAUTHORIZED);
    }
666951
public function logout(Request $request)
    {
        $event = new AccessControlEvent($request);
        /** @var Token $sessionAuth */
        $sessionAuth = $this->session()->get('authentication');
        $userId = $sessionAuth ? $sessionAuth->getToken()->getUserId() : false;
        if ($userId && $sessionAuth->getUser()) {
            $userName = $sessionAuth->getUser()->getUsername();
            $this->app['logger.system']->info('Logged out: ' . $userName, ['event' => 'authentication']);
            $event->setUserName($userName);
        }
        $this->app['dispatcher']->dispatch(AccessControlEvents::LOGOUT_SUCCESS, $event);

        // Clear the session
        $this->accessControl()->revokeSession();
        $this->session()->invalidate(-1);

        // Clear cookie data
        $response = $this->redirectToRoute('login');
        $response->headers->clearCookie(
            $this->app['token.authentication.name'],
            $request->getBasePath(),
            $this->getOption('general/cookies_domain'),
            $this->getOption('general/enforce_ssl')
        );

        return $response;
    }
163049
public function authenticate(Request $request)
    {
        if ($this->session->hasValue(User::SESSION_KEY)) {
            return $this->session->value(User::SESSION_KEY);
        }

        $user = $this->authenticationProvider->authenticate($request);
        if (null === $user) {
            return null;
        }

        $this->session->putValue(User::SESSION_KEY, $user);
        return $user;
    }