laravelemaillaravel-8fortifyemail-verification

Laravel 8 / Fortify - Email verification link not working (Safari)


I'm trying to get laravel's implemented email verification system working (https://laravel.com/docs/8.x/verification).

What i did so far:

  1. Enabled the Feature emailVerification in the file config/fortify.php like so:

    ...
    
    'features' => [
        Features::registration(),
        Features::resetPasswords(),
        Features::emailVerification(),
        Features::updateProfileInformation(),
        Features::updatePasswords(),
        Features::twoFactorAuthentication([
            'confirmPassword' => true,
        ]),
    ],
    
    ...
    
  2. implemented MustVeriffyEmail in the app/Models/User.php file like so:

    <?php
    
    namespace App\Models;
    
    use Illuminate\Contracts\Auth\MustVerifyEmail;
    use Illuminate\Database\Eloquent\Factories\HasFactory;
    use Illuminate\Foundation\Auth\User as Authenticatable;
    use Illuminate\Notifications\Notifiable;
    use Laravel\Fortify\TwoFactorAuthenticatable;
    use Laravel\Jetstream\HasProfilePhoto;
    use Laravel\Jetstream\HasTeams;
    use Laravel\Sanctum\HasApiTokens;
    
    class User extends Authenticatable implements MustVerifyEmail
    {
        use HasApiTokens;
        use HasFactory;
        use HasProfilePhoto;
        use HasTeams;
        use Notifiable;
        use TwoFactorAuthenticatable;
    
    ...
    

The result after these changes:
Everything is working just fine for Chrome or Firefox, except for Safari. If I try to click the email verification link which I get per mail it just redirects me to the login page (in a new tab) without any error messages. After logging in again it shows that it didn't work either. My email is now still unverified.

The link in the mail looks something like this:

http://127.0.0.1:8000/email/verify/3/995092d93501e0759262089b7ae6eac49b6fe656?expires=1614371149&signature=66ad8a8622e89a4936c71ca89e050cfcba602d7d4dfdcaca1b430a9e5396f49f

If I check my database, everything seems fine too, except I don't get any records in the email_verified_at column (which is present).

Maybe someone had the same issue and could help me out here?

Best regards,
Leon


Solution

  • Almost two years later I now write what I found out so far:


    Workaround (until today):

    As a workaround until today I went with a solution which is not very user-friendly.
    I just put the email-verification-link also as plain text in the footer of my verification-email with a quick note for safari users to copy this link and paste it directly in the browsers url in exactly the same tab which was used before (where the user is already logged in).
    This was the only solution on how I got it to work for Safari...

    The email footer looked something like this:

    enter image description here


    Today (from now on):

    As I was writing this answer I went on and tested the scenario again.
    I don't really know what happened in the meantime but for me it now just works as expected.
    Maybe it's because I'm now using Laravel 9 or maybe it's because I'm now using MacOS Ventura with Safari Version 16.1 (18614.2.9.1.12).


    Please let me know if I could help you somehow and if somebody knows the answer to what happened in the meantime I'm happy to hear what it was:)

    Leon