【发布时间】:2021-10-09 15:12:06
【问题描述】:
我正在使用带有身份验证系统的 Laravel 8.5。当用户想要更改密码时,它会发送一封带有链接的电子邮件。默认电子邮件包含如下所示的链接:
http://mywebsite/api/forgot-password?token=2ccece360b031db4dcadea0cbdf8dd47a1712632b727487a7226f19f8f607cc7&email=MyEmail%40gmail.com
我对电子邮件模板进行了一些更改。在 ResetPasswordNotification.php 我添加了这个:
public function toMail($notifiable)
{
return (new MailMessage)
->subject('MyApp password reset')
->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', $this->url)
->line('This password reset link will expire in 60 minutes.')
->line('If you did not request a password reset, no further action is required.');
}
在 User.php 中我有:
public function sendPasswordResetNotification($token)
{
$url = 'http://mywebsite/en/change-password?token=' . $token;
$this->notify(new ResetPasswordNotification($url));
}
现在我收到了这个链接:
http://mywebsite/en/change-password?token=8f87fc2d504507as385b4c47cb015cee4192749d3f1d641863524d513abb2a39
仅包含令牌而不包含电子邮件。如何向其中添加电子邮件,使其看起来像这样:
http://mywebsite/en/change-password?token=8f87fc2d504507as385b4c47cb015cee4192749d3f1d641863524d513abb2a39&email=UserEmail@gmail.com
谢谢!
【问题讨论】:
-
您只需将
$url = 'http://mywebsite/en/change-password?token=' . $token;更改为$url = 'http://mywebsite/en/change-password?token=' . $token . '&email=' . $this->email;(因为$this将引用User.php中的用户)。
标签: php laravel laravel-8 forgot-password