1

如何将电子邮件与令牌一起附加?

public function toMail($notifiable)
{
    if (static::$toMailCallback) {
        return call_user_func(static::$toMailCallback, $notifiable, $this->token);
    }

    return (new MailMessage)
        ->action(Lang::getFromJson('Reset Password'),
            url(config('http://mywebsite.local/') . 
                route('password.reset', $this->token, false)));
}

`

4

1 回答 1

0

如果您创建一个具有 2 列(或 3 列)的名为“password_reset”的表会更好。每一行都有一个 user_id 和一个唯一令牌,当用户提交“我忘记密码”表单时,您会生成并存储这些令牌。现在负责重置过程的路线将在此表单上password/reset/{user_id}/{token}

当用户访问该 URL 时,您必须验证令牌是否链接到 user_id,并且当用户提交重置密码表单时,您必须删除 password_reset 表中的该行。

于 2019-01-15T13:03:17.807 回答