diff --git a/src/Illuminate/Auth/Notifications/ResetPassword.php b/src/Illuminate/Auth/Notifications/ResetPassword.php index 00042d19c04d..585c35f529ff 100644 --- a/src/Illuminate/Auth/Notifications/ResetPassword.php +++ b/src/Illuminate/Auth/Notifications/ResetPassword.php @@ -59,20 +59,13 @@ public function via($notifiable) */ public function toMail($notifiable) { - if (static::$toMailCallback) { - return call_user_func(static::$toMailCallback, $notifiable, $this->token); - } + $resetUrl = $this->resetUrl($notifiable); - if (static::$createUrlCallback) { - $url = call_user_func(static::$createUrlCallback, $notifiable, $this->token); - } else { - $url = url(route('password.reset', [ - 'token' => $this->token, - 'email' => $notifiable->getEmailForPasswordReset(), - ], false)); + if (static::$toMailCallback) { + return call_user_func(static::$toMailCallback, $notifiable, $this->token, $resetUrl); } - return $this->buildMailMessage($url); + return $this->buildMailMessage($resetUrl); } /** @@ -91,6 +84,24 @@ protected function buildMailMessage($url) ->line(Lang::get('If you did not request a password reset, no further action is required.')); } + /** + * Get the reset URL for the given notifiable. + * + * @param mixed $notifiable + * @return string + */ + protected function resetUrl($notifiable) + { + if (static::$createUrlCallback) { + return call_user_func(static::$createUrlCallback, $notifiable, $this->token); + } + + return url(route('password.reset', [ + 'token' => $this->token, + 'email' => $notifiable->getEmailForPasswordReset(), + ], false)); + } + /** * Set a callback that should be used when creating the reset password button URL. *