我已經為我的 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 關注
- 159 瀏覽
添加回答
舉報
0/150
提交
取消