5
votes

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.

2

2 Answers

5
votes

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()),
    ]
);
0
votes

you can insert into AppServiceProvider->boot:

public function boot()
 {
      VerifyEmail::toMailUsing(function ($notifiable) {
          $verifyUrl = URL::temporarySignedRoute(
              'verification.verify', Carbon::now()->addMinutes(60),
              [
                  'id' => $notifiable->getKey(),
                  'hash' => sha1($notifiable->getEmailForVerification()),
              ]
          );
          return (new MailMessage)->subject('Welcome!')->markdown('emails.verify', ['url' => $verifyUrl]);
      });
 }

see email template is in views/emails/verify.blade.php