Laravel 6.0 - 自定义电子邮件验证:temporarySignedRoute() URL 不适用于新路由

Pel*_*lle 5 php routing laravel laravel-6

我正在尝试从 5.8 升级到 Laravel 6。我们使用Notification带有以下代码的自定义验证电子邮件来获取验证 URL:

URL::temporarySignedRoute(
    'verification.verify', 
    Carbon::now()->addMinutes(60), 
    [
        'id' => $notifiable->getKey(),
    ]
);
Run Code Online (Sandbox Code Playgroud)

这似乎生成了一个不适用于新路由的 URL(检查这个),例如:

URL::temporarySignedRoute(
    'verification.verify', 
    Carbon::now()->addMinutes(60), 
    [
        'id' => $notifiable->getKey(),
    ]
);
Run Code Online (Sandbox Code Playgroud)

到目前为止,我在网上找不到关于该特定主题的任何内容,因此如果您能帮助我使其在 Laravel 6 中正常工作,我将不胜感激。

提前致谢。

Pel*_*lle 5

好的,我在以下位置找到了解决方案:

vendor/laravel/framework/src/Illuminate/Auth/Notifications/VerifyEmail.php

不得不将代码更改为:

return URL::temporarySignedRoute(
    'verification.verify',
    Carbon::now()->addMinutes(60),
    [
        'id' => $notifiable->getKey(),
        'hash' => sha1($notifiable->getEmailForVerification()),
    ]
);
Run Code Online (Sandbox Code Playgroud)

  • 警告!!!您永远不应该更改“vendor”文件夹中的任何文件! (2认同)