Try logging in as a user with the given email and password.

@param $redirect the registered redirect URI
@return a valid {@link User}
@throws UserAuthenticationException if the user could not be logged in, with a reason
327934
static function tryLogin(\Db\Connection $db, $openid, $redirect) {
    if (!is_valid_url($openid)) {
      throw new UserSignupException("That is not a valid OpenID identity.");
    }
    if (!$redirect) {
      throw new \InvalidArgumentException("No redirect provided.");
    }

    $light = new \LightOpenID(\Openclerk\Config::get("openid_host"));

    if (!$light->mode) {
      // we still need to authenticate

      $light->identity = $openid;
      $light->returnUrl = $redirect;
      redirect($light->authUrl());
      return false;

    } else if ($light->mode == 'cancel') {
      // user has cancelled
      throw new UserSignupException("User has cancelled authentication.");

    } else {
      // otherwise login as necessary

      // optionally check for abuse etc
      if (!\Openclerk\Events::trigger('openid_validate', $light)) {
        throw new UserAuthenticationException("Login was cancelled.");
      }

      if ($light->validate()) {

        $q = $db->prepare("SELECT users.* FROM users
            JOIN user_openid_identities ON users.id=user_openid_identities.user_id
            WHERE identity=? LIMIT 1");
        $q->execute(array($light->identity));
        if ($user = $q->fetch()) {
          $result = new User($user);
          $result->setIdentity("openid:" . $light->identity);

          return $result;
        } else {
          throw new UserAuthenticationMissingAccountException("No account for the OpenID identity '" . $light->identity . "' was found.");
        }

      } else {
        $error = $light->validate_error ? $light->validate_error : "Please try again.";
        throw new UserSignupException("OpenID validation was not successful: " . $error);
      }
    }

  }
527377
public function authenticated(Request $request, Contracts\RequiresEmailVerification $user)
    {
        if (config('verification.verify') && !$user->isUserEmailVerified()) {
            Auth::guard($this->getGuard())->logout();

            return redirect($this->verificationRedirectPath());
        }

        return redirect()->intended($this->redirectPath());
    }
197625
public function doLogin()
    {
        $remember = Input::post('remember', false);
        $email    = Input::post('email');
        $redirect = Input::post('redirect');
        $redirect = ($redirect) ? $redirect : 'admin';

        try{
            $credential = array(
                'email'     => $email,
                'password'  => Input::post('password')
            );

            // Try to authenticate the user
            $user = Sentry::authenticate($credential, false);

            if($remember){
                Sentry::loginAndRemember($user);
            }else{
                Sentry::login($user, false);
            }

            Response::redirect($this->siteUrl($redirect));
        }catch(\Exception $e){
            App::flash('message', $e->getMessage());
            App::flash('email', $email);
            App::flash('redirect', $redirect);
            App::flash('remember', $remember);

            Response::redirect($this->siteUrl('login'));
        }
    }
681815
public function login(string $redirect_url = '') {
        if ( null === $guid = $this->getGuidFromQuery() ) {
            header( 'Location: ' . $this->getLoginUrl($redirect_url) );
            exit();
        } else {
            return $this->verify($guid);
        }
    }
545164
public function isAdmin($redirect = false)
    {

        if (!$this->isLoggedIn()) {
            $this->di->get("response")->redirect("user/login");
            return false;
        }

        $email = $this->di->get("session")->get("user");
        $user = new User();
        $user->setDb($this->di->get("db"));
        $user->find("email", $email);
        $isAdmin = $user->admin;

        if (!$isAdmin) {
            if ($redirect) {
                $this->di->get("response")->redirect("user");
            }
            return false;
        }

        return true;
    }
1150612
public function loginAction($request)
    {
        $data = $request->get('data');
        $userModel = new ModelUser();
        $validUser = $userModel->validateLogin($data['email'], $data['password']);

        if (!$validUser) {
            $this->setMessage('danger', 'Not valid user / password combination');
            return $this->redirect(url('login'));
        }

        $this->session()->set('user', $userModel->record);
        $this->sessionClearMessages();
        return $this->redirect('/');
    }
484600
public function createPasswordGrantClient($userId, $name, $redirect)
    {
        return $this->create($userId, $name, $redirect, false, true);
    }
1017653
public function start(Request $request, AuthenticationException $authException = null)
    {
        return new RedirectResponse($this->createLoginPath($request));
    }
307724
public function login(LoginRequest $request, JWTAuth $JWTAuth)
    {
        $credentials = $request->only(['email', 'password']);

        try {
            $token = \JWTAuth::attempt($credentials);

            event(new Login(\JWTAuth::user(), false));

            if (!$token) {
                throw new AccessDeniedHttpException(__('auth.failed'));
            }

        } catch (JWTException $e) {
            throw new HttpException(500);
        }

        return response()
            ->json([
                'status'     => 'ok',
                'token'      => $token,
                'expires_in' => Auth::guard()->factory()->getTTL() * 60
            ]);
    }
1132904
public function authenticateAction(Request $request) {
        $data = $request->request->all();
        try {
            $data = $this->getAuthCredentials($request);
            $this->info('> Authenticate request', ['method' => $request->getMethod(), 'query' => $data]);
            // exports $client_id, $redirect_uri, $username and $password
            extract($data);

            $accessCredentials = $this->accessProvider->generate($request, $client_id, $redirect_uri, $username, $password);
            $response = new RedirectResponse($redirect_uri . '?code=' . $accessCredentials->getAuthCode());
        }catch (BadDataException $e) {
            $data['errors'] = $e->getErrors();
            $this->error('Bad Data Exception: ' . $e->getMessage(), ['errors' => $data['errors'], 'exception' => $e]);
            $response = $this->getBadFormRequestResponse($data);
        } catch (SoauthException $e) {
            $this->error('Soauth Exception: ' . $e->getMessage(), ['exception' => $e]);
            $response = $this->getBadFormRequestResponse($data);
        }

        $this->info('< Response', ['status_code' => $response->getStatusCode(), 'target' => $response instanceOf RedirectResponse ? $response->getTargetUrl() : null]);
        return $response;
    }
89634
public function authenticate()
    {

                $email = Input::get('email');
        $password = Input::get('password');
        $returnURL = Input::get('returnURL');

        
        if (Auth::attempt(['email' => $email, 'password' => $password])) {
            // Authentication passed...
            // return redirect()->intended('dashboard');
             return redirect($returnURL);
        }
    }
332388
private function getRedirect($currentRoute, $redirect = false)
    {
        $useRedirect = $this->options->getUseRedirectParameterIfPresent();
        $routeExists = ($redirect && $this->routeExists($redirect));
        if (!$useRedirect || !$routeExists) {
            $redirect = false;
        }

        switch ($currentRoute) {
            case 'zfcuser/login':
            case 'scn-social-auth-user/login':
            case 'scn-social-auth-user/register':
            case 'scn-social-auth-user/authenticate/provider':
            case 'scn-social-auth-user/add-provider/provider':
                $route = ($redirect) ?: $this->options->getLoginRedirectRoute();

                return $this->router->assemble(array(), array('name' => $route));
                break;
            case 'zfcuser/logout':
            case 'scn-social-auth-user/logout':
                $route = ($redirect) ?: $this->options->getLogoutRedirectRoute();

                return $this->router->assemble(array(), array('name' => $route));
                break;
            default:
                return $this->router->assemble(array(), array('name' => 'zfcuser'));
        }
    }
832246
public function createPersonalAccessClient($userId, $name, $redirect)
    {
        return tap($this->create($userId, $name, $redirect, true), function ($client) {
            $accessClient = Passport::personalAccessClient();
            $accessClient->client_id = $client->id;
            $accessClient->save();
        });
    }
1049239
public function loginPage($redirect, $identification = null)
    {
        $preAuthCode = $this->createPreAuthCode($identification);

        // 拼接出微信公众号登录授权页面url
        return sprintf(self::COMPONENT_LOGIN_PAGE, $this->appid, $preAuthCode, urlencode($redirect));
    }
764452
public function getUserWithCredentials($username, $password)
    {
        if (empty($username)) {
            throw new AuthException('Please enter a valid username.');
        }

        if (empty($password)) {
            throw new AuthException('Please enter a valid password.');
        }

        // look the user up with the given username
        $usernameWhere = $this->buildUsernameWhere($username);
        $userClass = $this->auth->getUserClass();
        $user = $userClass::where($usernameWhere)
                          ->first();

        if (!$user) {
            throw new AuthException('We could not find a match for that email address and password.');
        }

        if (!$this->verifyPassword($user, $password)) {
            throw new AuthException('We could not find a match for that email address and password.');
        }

        if ($user->isTemporary()) {
            throw new AuthException('It looks like your account has not been setup yet. Please go to the sign up page to finish creating your account.');
        }

        if (!$user->isEnabled()) {
            throw new AuthException('Sorry, your account has been disabled.');
        }

        if (!$user->isVerified()) {
            throw new AuthException('You must verify your account with the email that was sent to you before you can log in.');
        }

        // success!
        return $user;
    }
783062
public function loginWith()
    {
        $providerName = $_REQUEST["provider"];
        $redirect = $_GET['redirect'];

        $userProfile = $this->getAuthProvider()->authenticate($providerName);

        if ($userProfile instanceof Exception) {
            $this->getView()->set('exception', $userProfile);
        } else {
            $userExist = User_Logins::instance()->getUserByProvider($providerName, $userProfile->identifier);

            if (!$userExist) {
                $this->redirect(
                    $this->getModelManager()->getOAuthLinkURL([
                        'provider' => $providerName,
                        'redirect' => $redirect
                    ]));
            }

            $userExist->doAuthentication();

            $this->afterLoginRedirect();
        }
    }
1021722
public function actionLogout($redirect = null)
	{
		\App::$domain->account->auth->logout();
		\App::$domain->navigation->alert->create(['account/auth', 'logout_success'], Alert::TYPE_SUCCESS);
		if($redirect) {
            return $this->redirect([SL . $redirect]);
        } else {
            return $this->goHome();
        }
	}