Devise\Users\Sessions\SessionsRepository::login PHP Method

login() public method

Attempty to login a user
public login ( array $input ) : User
$input array
return User
    public function login($input)
    {
        try {
            if ($user = $this->attemptUserLogin($input)) {
                $this->message = 'You have been logged in.';
                return $user;
            }
            $this->message = 'There were validation errors.';
            $this->errors = 'Invalid credentials or user is not active.';
            return false;
        } catch (UserNotFoundException $e) {
            $this->message = 'User not found.';
            return false;
        } catch (UserNotActivatedException $e) {
            $this->message = 'User has not been activated.';
            return false;
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Executes login method in SessionsRepository
  *
  * @param  array  $input
  * @return Response
  */
 public function requestLogin($input)
 {
     if ($this->SessionsRepository->login($input)) {
         if (isset($input['intended'])) {
             return $this->Redirect->to($input['intended']);
         }
         return $this->Redirect->route('dvs-dashboard');
     }
     return $this->Redirect->route('dvs-user-login')->withInput()->withErrors($this->SessionsRepository->errors)->with('message-errors', $this->SessionsRepository->message);
 }