Laravel Logout路由重定向但登录仍然存在

时间:2016-08-24 23:39:13

标签: php laravel-5.2

我正在使用Laravel 5.2,这是我的退出路线:

Route::get('/logout', [ 'uses' => 'Auth\AuthController@getLogout', 'as' => 'logout']);

当我导航到/logout时,我将重定向返回主页,但我没有退出。当我尝试去受保护的路线时,如下:

Route::get('/amIloggedout',['middleware' => 'auth',
    'uses' => 'MomsController@firstPass',
    'as'   => 'moms.Logout'
]);

它让我直接进入,该控制器生成的视图也传递告诉我我已登录的信息(显示我的用户名)。

那个控制器在这里,我不认为我无意中自动重新登录:

public function firstPass()
{
if(Auth::user()->Type=="Employee" || Auth::user()->Type=="ADMIN")
{
//retrieve data or else echo ACCESS DENIED below

所以我不明白为什么它不起作用?也许是因为我使用用户名而不是电子邮件登录?但是我查看了@getLogout函数,它似乎并不关心你如何登录,而是关于注销。

public function getLogout()
    {
        return $this->logout();
    }

    /**
     * Log the user out of the application.
     *
     * @return \Illuminate\Http\Response
     */
    public function logout()
    {
        Auth::guard($this->getGuard())->logout();

        return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
    }

那么我做错了什么?注销在我的其他应用程序中一直运行良好,所以我想知道我无意中做了什么。

1 个答案:

答案 0 :(得分:0)

将注销路线更改为:

Route::get('/logout', [ 'uses' => 'Auth\AuthController@logout', 'as' => 'logout']);

让它工作,但我真的不明白为什么@getLogout无论如何调用@logout都不起作用?哦,很高兴让它工作。 :)

相关问题