I'm working with Laravel 5 authentification system provided by default. After logging out, a user is redirected to the root page but I'd like to change that. I managed to do it for the "login" and "registering" process by defining "$redirectTo" in "AuthController.php". But for "logout", I defined "$redirectAfterLogout" at the same place but it seems to not be taken into account.
Could anyone explain me where is the problem and how to fix it please? Thanks a lot.
In App\Controllers\Auth\AuthController, add the following two variables.
You get the idea.
For Laravel 5.5 override logout method inside LoginController. In my case I am redirecting to home route after login.
Add this to your route
Route::get('logout', function(){ Auth::logout(); return redirect('/'); /Added this line. The auth doesn't seem to work on its own/ });
For Laravel 5,
Open
AuthController
class : app/Http/Controllers/Auth/AuthController.phpAdd below property to the class
you can change
auth/login
with any url.it'only laravel versi 5.4 if you want custom redirect url logout, open
/your-project-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php
and edit redirect based on you neededI have a same problem in Laravel 5.0. Override a method does the trick.
1) Go to app/Http/Controllers/Auth/AuthController.php 2) Add a new method :