在 Laravel 中的令牌旁边添加电子邮件忘记密码模板电子邮件链接

问题描述 投票:0回答:2

我正在使用 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 protected]
php laravel laravel-8 forgot-password
2个回答
3
投票

尝试将电子邮件传递到该网址。

public function sendPasswordResetNotification($token)
{    
    $url = 'http://mywebsite/en/change-password?token=' . $token . '&email=' .$this->email;    
    $this->notify(new ResetPasswordNotification($url));
}

2
投票

只需在

$this->email
旁边添加
$token

public function sendPasswordResetNotification($token)
{    
    $url = 'http://mywebsite/en/change-password?token=' . $token . '&email=' . $this->email;    
    $this->notify(new ResetPasswordNotification($url));
}
© www.soinside.com 2019 - 2024. All rights reserved.