Skip to content

Commit

Permalink
cleaning up password reset notification
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jun 20, 2016
1 parent e23e05e commit 3d74a12
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
13 changes: 13 additions & 0 deletions src/Illuminate/Auth/Passwords/CanResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Illuminate\Auth\Passwords;

use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;

trait CanResetPassword
{
/**
Expand All @@ -13,4 +15,15 @@ public function getEmailForPasswordReset()
{
return $this->email;
}

/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token));
}
}
14 changes: 4 additions & 10 deletions src/Illuminate/Auth/Passwords/PasswordBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Auth\PasswordBroker as PasswordBrokerContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;

class PasswordBroker implements PasswordBrokerContract
{
Expand Down Expand Up @@ -51,10 +50,9 @@ public function __construct(TokenRepositoryInterface $tokens,
* Send a password reset link to a user.
*
* @param array $credentials
* @param \Closure|null $callback
* @return string
*/
public function sendResetLink(array $credentials, Closure $callback = null)
public function sendResetLink(array $credentials)
{
// First we will check to see if we found a user at the given credentials and
// if we did not we will redirect back to this current URI with a piece of
Expand All @@ -68,13 +66,9 @@ public function sendResetLink(array $credentials, Closure $callback = null)
// Once we have the reset token, we are ready to send the message out to this
// user with a link to reset their password. We will then redirect back to
// the current URI having nothing set in the session to indicate errors.
if ($callback) {
call_user_func($callback, $user, $this->tokens->create($user));
} else {
$user->notify(new ResetPasswordNotification(
$this->tokens->create($user)
));
}
$user->sendPasswordResetNotification(
$this->tokens->create($user)
);

return static::RESET_LINK_SENT;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Illuminate/Contracts/Auth/CanResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ interface CanResetPassword
* @return string
*/
public function getEmailForPasswordReset();

/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token);
}
3 changes: 1 addition & 2 deletions src/Illuminate/Contracts/Auth/PasswordBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ interface PasswordBroker
* Send a password reset link to a user.
*
* @param array $credentials
* @param \Closure|null $callback
* @return string
*/
public function sendResetLink(array $credentials, Closure $callback = null);
public function sendResetLink(array $credentials);

/**
* Reset the password for the given token.
Expand Down

0 comments on commit 3d74a12

Please sign in to comment.