重定向回job_seeker.register

时间:2019-09-28 00:43:55

标签: laravel-5.8 laravel-authentication

我是laravel 5.8的新手,尝试设置多重身份验证,但是在我注册了一个新的job_seeker之后,它想将我重定向到job_seeker.profile,而是将我重定向回job_seeker.register

我在stackoverflow中尝试了一些代码,但是没有用

public function render($request, Exception $exception)
    {
        return parent::render($request, $exception);
    }
    protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }

        return redirect()->guest(route($login));
    }




protected function unauthenticated($request, AuthenticationException $exception)
    {

        if ($request->expectsJson())
        {
            return response()->json(['message' => $exception->getMessage()], 401);
        }

        $guard = array_get($exception->guards(), 0);

        switch ($guard) {
            case 'job_seeker':
                $login = 'job_seeker.register';
                break;

            case 'employer':
                $login = 'employer.register';
                break;

            default:
                $login = 'login';
                break;
        }

        return redirect()->guest(route($login));
    }


 Route::post('job_seeker.login',['as'=>'job_seeker.login','uses'=>'job_seeker\login_job_seeker_Controller@login']);
        Route::get('job_seeker.register',['as'=>'job_seeker.register','uses'=>'job_seeker\login_job_seeker_Controller@show_login_form']);
        Route::get('job_seeker.profile',['as'=>'job_seeker.profile','uses'=>'job_seeker\job_seeker_profile_controller@show_profile']);  

0 个答案:

没有答案