简体   繁体   中英

How Can I Attach an Email With Laravel Default Reset Password Link

How can I attach an email along with the token?

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)));
}

`

it would be better if you create a table called "password_reset" that has 2 columns ( or 3 ). each row has a user_id and a unique token that you generate and store when the user submits the "I forgot my password" form. now the route that takes care of the reset process will be on this form password/reset/{user_id}/{token} .

when the user access to that URL, you must verify that the token is linked to the user_id, and when the user submits the reset password form, you must delete that row on your password_reset table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM