tgif's avatar
Level 4

User unable to logout in L5.1.12

Hi Guys, For some reason Laravel refuses to logout. When I print out my route:list, everything looks fine:

 GET|HEAD | auth/logout | App\Http\Controllers\Auth\AuthController@getLogout    | guest

In the AuthenticatesUsers.php file i try to dd..

public function getLogout()
{
    dd('In logout');
...

but I get a 302 server error.

Remote Address:127.0.0.1:80
Request URL:http://controlcenter.dev/auth/logout
Request Method:GET
Status Code:302 Found

Does my page ever reach the getLogout method?

This is shocking because this whole time I've been working on bulk file uploads.

Does anyone know where else I can look for the solution?

thanks

0 likes
6 replies
thomaskim's avatar

@csuarez You're getting that error because you applied the guest middleware on it. If someone is logged in, they are not a guest. Therefore, they will never reach that function since the middleware prevents them from triggering it.

tgif's avatar
Level 4

hi thanks @thomaskim, even if my AuthController constructor looks like this?

public function __construct()
{
     $this->middleware('guest', ['except' => 'getLogout', 
                              'except' => 'postAvatar']);
}

also, is my session supposed to look like this?

http://oi60.tinypic.com/2yjvbrd.jpg

fwartner's avatar

getLogoutshouldn´t exist in your except array..

thomaskim's avatar
Level 41

@csuarez Try this instead:

$this->middleware('guest', ['except' => ['getLogout', 'postAvatar']]);
tgif's avatar
Level 4

thank you @thomaskim that solved the issue. I am incredibly appreciative of you help.

Please or to participate in this conversation.