Support the ongoing development of Laravel.io →
posted 8 years ago
Authentication
Last updated 2 years ago.
0

Use this in routes.php Route::get('auth/logout', 'Auth\AuthController@getLogout'); and add <a href="{{ url('/auth/logout') }}" >Logout</a> in your view . It's a builtin functionality. I mean Auth.

0

I also had similar problem in Laravel 5.2. You should change your route to

Route::get('auth/logout', 'Auth\AuthController@logout');

or in AuthController constructor add

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

That worked for me.

0

Pawlox said:

I also had similar problem in Laravel 5.2. You should change your route to

Route::get('auth/logout', 'Auth\AuthController@logout');

or in AuthController constructor add

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

That worked for me.

Thank you , you save my life

0

Thank you too. I have been pulling my hair out.

Which is best practice?

0

Check this

https://laracasts.com/discuss/channels/laravel/logout-wont-work?page=1#reply-138472

you just need to fix your AuthController

 /**
         * Create a new authentication controller instance.
         *
         * @return void
         */
        public function __construct()
        {
            $this->middleware('guest', [ 'except' => 'logout' ]); // Default router name is "logout" should be same router 

        }

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

0

Pawlox said:

I also had similar problem in Laravel 5.2. You should change your route to

Route::get('auth/logout', 'Auth\AuthController@logout');

or in AuthController constructor add

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

That worked for me.

Thanks, bro! Much appreciated!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

fpena fpena Joined 27 Dec 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.