Laravel 8 / Fortify - 电子邮件验证链接无效Safari

问题描述

我正在努力让 Laravel 实施的电子邮件验证系统正常工作 (https://laravel.com/docs/8.x/verification)。

到目前为止我做了什么:

  1. 文件 config/fortify.PHP 中启用功能 emailVerification,如下所示:

    ...
    
    'features' => [
        Features::registration(),Features::resetPasswords(),Features::emailVerification(),Features::updateProfileinformation(),Features::updatePasswords(),Features::twoFactorAuthentication([
            'confirmPassword' => true,]),],...
    
  2. app/Models/User.PHP 文件中实现了 MustVeriffyEmail,如下所示:

    <?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;
    
    ...
    

经过这些编辑后,我的结果是一切正常,除了我每封邮件收到的电子邮件验证链接。如果我尝试单击链接,它只会将我重定向登录页面,而没有任何错误消息。

邮件中的链接如下所示:

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

如果我检查我的数据库,一切似乎也很好,除了我在 email_verified_at 列(存在)中没有得到任何记录。

也许有人遇到了同样的问题,可以帮我解决这个问题吗?

最好的问候, 莱昂

解决方法

你缺少工具

class User extends Authenticatable implements MustVerifyEmail