Example #1
0
 public function postReset()
 {
     $this->beforeFilter('csrf');
     // Use the same password validation rules
     // from the user model
     $rules = array('code' => 'required', 'email' => 'required|email', 'password' => User::$rules['password'] . '|confirmed');
     $validator = Validator::make(Input::all(), $rules);
     if (!$validator->fails()) {
         try {
             $user = Sentry::findUserByCredentials(array('email' => Input::get('email')));
             if ($user->checkResetPasswordCode(Input::get('code'))) {
                 if ($user->attemptResetPassword(Input::get('code'), Input::get('password'))) {
                     // Password reset passed
                     Mail::queue(array('emails.password.done', 'emails.password.done_text'), array(), function ($message) use($user) {
                         $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Password Reset Successful');
                     });
                     return Redirect::action('AuthController@getDone');
                 } else {
                     // Password reset failed
                     Session::flash('error', 'Your password could not be reset');
                 }
             } else {
                 // The provided password reset code is Invalid
                 Session::flash('error', 'Invalid password reset code');
             }
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             Session::flash('error', 'User not found, please check your email address');
         }
     } else {
         Session::flash('error', 'Please correct the following errors and try again');
     }
     Input::flash();
     return Redirect::action('AuthController@getReset')->withErrors($validator);
 }
Example #2
0
 /**
  * Return user found by given credentials.
  *
  * @param array $credentials
  * @return bool
  */
 public function findByCredentials(array $credentials)
 {
     try {
         $user = Sentry::findUserByCredentials($credentials);
     } catch (UserNotFoundException $e) {
         $this->error = 'Cant find user with given credentials.';
         return false;
     }
     return $user;
 }
Example #3
0
 /**
  * Find a user by its credentials
  * @param  array $credentials
  * @return mixed
  * @throws BaseUserNotFoundException
  */
 public function findByCredentials(array $credentials)
 {
     try {
         $user = Sentry::findUserByCredentials($credentials);
     } catch (\Exception $e) {
         throw new BaseUserNotFoundException();
     }
     return $user;
 }