成功验证后,Laravel重定向到登录页面

时间:2020-05-12 14:14:17

标签: laravel email-verification

我实现了MustVerifyEmail来验证注册用户。我想要的是,通过电子邮件成功验证后,它将重定向到登录页面。尝试执行此操作,但仍然将其重定向到/ home。

VerificationController.php

class VerificationController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Email Verification Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling email verification for any
    | user that recently registered with the application. Emails may also
    | be re-sent if the user didn't receive the original email message.
    |
    */

    use VerifiesEmails;

    /**
     * Where to redirect users after verification.
     *
     * @var string
     */
    //protected $redirectTo = '/home';

    protected function redirectTo()
    {
        //generate URL dynamicaly .
        return '/login'; // return dynamicaly generated URL.
    }

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //$this->middleware('auth');
        $this->middleware('signed')->only('verify');
        $this->middleware('throttle:6,1')->only('verify', 'resend');
    }

}

1 个答案:

答案 0 :(得分:0)

返回视图('/'); 或尝试使用php artisan config:cache