问题描述
我正在努力让 Laravel 实施的电子邮件验证系统正常工作 (https://laravel.com/docs/8.x/verification)。
到目前为止我做了什么:
-
在文件 config/fortify.PHP 中启用功能 emailVerification,如下所示:
... 'features' => [ Features::registration(),Features::resetPasswords(),Features::emailVerification(),Features::updateProfileinformation(),Features::updatePasswords(),Features::twoFactorAuthentication([ 'confirmPassword' => true,]),],...
-
在 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; ...
经过这些编辑后,我的结果是一切正常,除了我每封邮件收到的电子邮件验证链接。如果我尝试单击链接,它只会将我重定向到登录页面,而没有任何错误消息。
如果我检查我的数据库,一切似乎也很好,除了我在 email_verified_at 列(存在)中没有得到任何记录。
也许有人遇到了同样的问题,可以帮我解决这个问题吗?
最好的问候, 莱昂
解决方法
你缺少工具
class User extends Authenticatable implements MustVerifyEmail