Laravel 6.0 - Custom email verification: temporarySignedRoute() URL not working with new route

巧了我就是萌 提交于 2020-12-08 10:42:51

问题


I'm trying to upgrade to Laravel 6 from 5.8. We're using a custom verification email Notification with the following code to get the verification URL:

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

This seems to generate an URL that does not work with the new route (check this), for example:

http://host/email/verify/38?expires=1574602925&signature=4410c2230623619633be56d3641814cea3c77236bf8435cba88fc102a35d3dc4

I couldn't find anything on that specific topic online so far, so I'd appreciate any help to get this to work in Laravel 6.

Thanks in advance.


回答1:


Okay, I found the solution in:

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

Had to change the code to:

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


来源:https://stackoverflow.com/questions/59018355/laravel-6-0-custom-email-verification-temporarysignedroute-url-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!