Laravel 电子邮件验证链接不起作用?

我已经为我的 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


<?php


namespace 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';


}


蛊毒传说
浏览 130回答 1
1回答

海绵宝宝撒

确保您的身份验证路径不在身份验证中间件中Auth::routes(['verify' => true]);Route::group(['middleware' => 'auth'], function () {});
打开App,查看更多内容
随时随地看视频慕课网APP