我已经为我的 Laravel APP 设置了电子邮件验证,但是当我注册为用户并转到 mailtrap.io 并且当我单击“验证电子邮件地址”按钮时,我得到 403 This action is unauthorized,但是如果我单击重新发送验证邮件,然后单击它工作正常的按钮。这是我的网络路线:Auth::routes(['verify' => true]);Route::get('/home', 'HomeController@index')->name('home');Route::get('/', 'HomeController@index')->name('home');Route::resource('challenge', 'ChallengesController');Route::post('/challenge/join/{id}', 'ChallengesController@joinChallenge')->name('challenge.join');Route::delete('/challenge/finish/{id}', 'ChallengesController@finishChallenge')->name('challenge.finish');在我的用户模型中,我实现了 MustVerifyEmail<?phpnamespace App;use Illuminate\Contracts\Auth\MustVerifyEmail;use Illuminate\Foundation\Auth\User as Authenticatable;use Illuminate\Notifications\Notifiable;class User extends Authenticatable implements MustVerifyEmail{ use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'user_id', 'name', 'username', 'email', 'password', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; protected $primaryKey = 'user_id'; protected $keyType = 'string';}
1 回答
海绵宝宝撒
TA贡献1809条经验 获得超8个赞
确保您的身份验证路径不在身份验证中间件中
Auth::routes(['verify' => true]);
Route::group(['middleware' => 'auth'], function () {
});
- 1 回答
- 0 关注
- 129 浏览
添加回答
举报
0/150
提交
取消