我的路线如下
Route::group(['middleware' => ['web']], function () {
Route::get('/', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
});
Route::group(['middleware' => ['web', 'auth']], function () {
Route::get('/Roles', array('uses' => 'RoleController@Roles', 'as' => 'Roles'));
});
成功验证后,我可以看到角色列表,并且有注销按钮。单击“注销”按钮将转到class RedirectIfAuthenticated
。
我们在这个课程中有处理方法
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/');
}
return $next($request);
}
如果条件和问题即将到来,它会进入。
我错过了什么吗?
答案 0 :(得分:0)
默认情况下,AuthController将guest虚拟机中间件放在除logout
之外的所有方法上。您的路线是getLogout
。调整AuthController中的中间件声明或调整路径以使用默认方法logout
。
答案 1 :(得分:0)
AuthController构造函数应该如下所示,问题得到解决。
public function __construct()
{
//$this->middleware('guest', ['except' => 'logout']);
}