Skip to content

Commit

Permalink
align reset url creation (#39652)
Browse files Browse the repository at this point in the history
  • Loading branch information
okaufmann committed Nov 17, 2021
1 parent b2be94b commit e75a59e
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/Illuminate/Auth/Notifications/ResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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.
*
Expand Down

0 comments on commit e75a59e

Please sign in to comment.