成功验证后,Laravel重定向到登录页面 [英] Laravel Redirect To Login Page After Successful Verification

查看:88
本文介绍了成功验证后,Laravel重定向到登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I implements MustVerifyEmail to verify registered user. What I want is it will redirect to login page after successful verification by email. Trying to do this, but still, it keep redirect to /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');
    }

}

推荐答案

return view('/');或尝试使用php artisan config:cache

return view('/'); or try php artisan config:cache

这篇关于成功验证后,Laravel重定向到登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆