예제 #1
0
파일: Basic.php 프로젝트: devdk/signy
 /**
  * Authenticate request.
  *
  * @return bool|exception
  */
 public function auth()
 {
     if (!$this->auth->attempt($this->getCredentials())) {
         throw new InvalidBasicAuthCredentials();
     }
     return true;
 }
 /**
  * Handle the command
  *
  * @param $command
  * @throws InvalidCredentialsException
  * @return mixed
  */
 public function handle($command)
 {
     foreach ($this->availableIdentifiers() as $identifier) {
         $attemptable = [$identifier => $command->identifier, 'password' => $command->password];
         if ($this->authManager->attempt($attemptable, $command->remember)) {
             return true;
         }
     }
     $this->throwError();
 }
예제 #3
0
 /**
  * @param $username
  * @param $password
  * @throws MissingInput
  * @throws AuthenticationFailed
  */
 public function login($username, $password)
 {
     $missing_fields = [];
     if (!$username || $username === '') {
         $missing_fields[] = 'username';
     }
     if (!$password || $password === '') {
         $missing_fields[] = 'password';
     }
     if (count($missing_fields) > 0) {
         throw new MissingInput($missing_fields);
     }
     if (!$this->auth->attempt(array('email' => $username, 'password' => $password))) {
         throw new AuthenticationFailed();
     }
 }
예제 #4
0
 public function handleLogin(AuthManager $auth, Request $request)
 {
     // Set the auth data
     $userData = ['email' => $request->get('email'), 'password' => $request->get('password')];
     // Log in successful
     if ($auth->attempt($userData)) {
         return redirect()->intended(route('home'))->with('message', 'You have been logged in.');
     }
     // Login failed
     return redirect(route('auth.login'))->with('error', 'Your username or password was incorrect.');
 }
예제 #5
0
 public function postLogin()
 {
     if ($this->auth->attempt($this->request->only('email', 'password'))) {
         $url = $this->request->get("url");
         if ($url == null) {
             return $this->redirector->route("dashboard");
         }
         return $this->redirector->to($this->request->get("url"));
     }
     return $this->redirector->route('home');
 }
예제 #6
0
 /**
  * Given correct credentials, log a user in.
  *
  * @param  array   $credentials
  * @param  boolean $remember
  *
  * @return bool
  * @throws AuthenticationException
  */
 public function login(array $credentials, $remember = false)
 {
     $credentials['is_active'] = 1;
     // if the "eloquent-exceptions" driver is being used, an exception will
     // be thrown if authentication failed. if one of the stock drivers are
     // being used, it will just return false, and we have to throw the
     // exception ourselves, with less information.
     if (!$this->auth->attempt($credentials, $remember)) {
         throw new AuthenticationException('Illuminate\\Auth\\Guard::attempt returned false');
     }
     $this->getCurrentUser()->rehashPassword($credentials['password']);
     return true;
 }
 /**
  * Show the login form
  *
  * @return mixed
  */
 public function postIndex()
 {
     // Pick up the honeypot field to stop bots, return to the login screen, no message
     if ($this->request->get('potter')) {
         return $this->redirect->to('auth/login')->withInput();
     }
     if (!$this->validator->with($this->request->all())->passes()) {
         return $this->redirect->to('auth/login')->withErrors($this->validator->errors());
     }
     if ($this->auth->attempt(['username' => $this->request->get('username'), 'password' => $this->request->get('password')])) {
         return $this->redirect->intended('/');
     }
     $this->session->flash('failed', trans('auth.incorrect_username_or_password'));
     return $this->redirect->to('auth/login')->withInput();
 }
예제 #8
0
 public function run()
 {
     if (!$this->auth->attempt($this->credentials, $this->remember)) {
         $this->addError('Invalid username / password combination');
     }
 }
예제 #9
0
 public function login($email, $password, $remember = false)
 {
     return $this->auth->attempt(compact('email', 'password'), $remember);
 }