Skip to content

Commit

Permalink
Fixed forgotten password
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Jul 25, 2015
1 parent e944b2d commit 7d67b6a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,18 @@ public function postForgotPassword()
// Get the user password recovery code
$user = Sentry::getUserProvider()->findByLogin(Input::get('username'));

$reset = $user->getResetPasswordCode();

// Data to be used on the username view
$data = array(
'user' => $user,
'forgotPasswordUrl' => URL::route('forgot-password-confirm', $user->getResetPasswordCode()),
'forgotPasswordUrl' => URL::route('forgot-password-confirm', $reset),
);

$user->reset_password_code = $reset;
$user->save();


// Send the activation code through username
Mail::send('emails.forgot-password', $data, function ($m) use ($user) {
$m->to($user->username, $user->first_name . ' ' . $user->last_name);
Expand All @@ -165,12 +171,13 @@ public function postForgotPassword()
*/
public function getForgotPasswordConfirm($passwordResetCode = null)
{

try {
// Find the user using the password reset code
$user = Sentry::getUserProvider()->findByResetPasswordCode($passwordResetCode);
} catch(Cartalyst\Sentry\Users\UserNotFoundException $e) {
// Redirect to the forgot password page
return Redirect::route('forgot-password')->with('error', Lang::get('auth/message.account_not_found'));
//return Redirect::route('forgot-password')->with('error', Lang::get('auth/message.account_not_found'));
}

// Show the page
Expand Down

0 comments on commit 7d67b6a

Please sign in to comment.