Skip to content

Commit 3d74a12

Browse files
committed
cleaning up password reset notification
1 parent e23e05e commit 3d74a12

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

src/Illuminate/Auth/Passwords/CanResetPassword.php

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Illuminate\Auth\Passwords;
44

5+
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
6+
57
trait CanResetPassword
68
{
79
/**
@@ -13,4 +15,15 @@ public function getEmailForPasswordReset()
1315
{
1416
return $this->email;
1517
}
18+
19+
/**
20+
* Send the password reset notification.
21+
*
22+
* @param string $token
23+
* @return void
24+
*/
25+
public function sendPasswordResetNotification($token)
26+
{
27+
$this->notify(new ResetPasswordNotification($token));
28+
}
1629
}

src/Illuminate/Auth/Passwords/PasswordBroker.php

+4-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Illuminate\Contracts\Auth\UserProvider;
99
use Illuminate\Contracts\Auth\PasswordBroker as PasswordBrokerContract;
1010
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
11-
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
1211

1312
class PasswordBroker implements PasswordBrokerContract
1413
{
@@ -51,10 +50,9 @@ public function __construct(TokenRepositoryInterface $tokens,
5150
* Send a password reset link to a user.
5251
*
5352
* @param array $credentials
54-
* @param \Closure|null $callback
5553
* @return string
5654
*/
57-
public function sendResetLink(array $credentials, Closure $callback = null)
55+
public function sendResetLink(array $credentials)
5856
{
5957
// First we will check to see if we found a user at the given credentials and
6058
// if we did not we will redirect back to this current URI with a piece of
@@ -68,13 +66,9 @@ public function sendResetLink(array $credentials, Closure $callback = null)
6866
// Once we have the reset token, we are ready to send the message out to this
6967
// user with a link to reset their password. We will then redirect back to
7068
// the current URI having nothing set in the session to indicate errors.
71-
if ($callback) {
72-
call_user_func($callback, $user, $this->tokens->create($user));
73-
} else {
74-
$user->notify(new ResetPasswordNotification(
75-
$this->tokens->create($user)
76-
));
77-
}
69+
$user->sendPasswordResetNotification(
70+
$this->tokens->create($user)
71+
);
7872

7973
return static::RESET_LINK_SENT;
8074
}

src/Illuminate/Contracts/Auth/CanResetPassword.php

+8
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,12 @@ interface CanResetPassword
1010
* @return string
1111
*/
1212
public function getEmailForPasswordReset();
13+
14+
/**
15+
* Send the password reset notification.
16+
*
17+
* @param string $token
18+
* @return void
19+
*/
20+
public function sendPasswordResetNotification($token);
1321
}

src/Illuminate/Contracts/Auth/PasswordBroker.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ interface PasswordBroker
4545
* Send a password reset link to a user.
4646
*
4747
* @param array $credentials
48-
* @param \Closure|null $callback
4948
* @return string
5049
*/
51-
public function sendResetLink(array $credentials, Closure $callback = null);
50+
public function sendResetLink(array $credentials);
5251

5352
/**
5453
* Reset the password for the given token.

0 commit comments

Comments
 (0)