我已經(jīng)為我的 Laravel APP 設(shè)置了電子郵件驗(yàn)證,但是當(dāng)我注冊為用戶并轉(zhuǎn)到 mailtrap.io 并且當(dāng)我單擊“驗(yàn)證電子郵件地址”按鈕時(shí),我得到 403 This action is unauthorized,但是如果我單擊重新發(fā)送驗(yàn)證郵件,然后單擊它工作正常的按鈕。這是我的網(wǎng)絡(luò)路線: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');在我的用戶模型中,我實(shí)現(xiàn)了 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貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個(gè)贊
確保您的身份驗(yàn)證路徑不在身份驗(yàn)證中間件中
Auth::routes(['verify' => true]);
Route::group(['middleware' => 'auth'], function () {
});
- 1 回答
- 0 關(guān)注
- 156 瀏覽
添加回答
舉報(bào)
0/150
提交
取消