0

In laravel 5.4, where is the file location of "auth" middleware as I can change the default redirect path after logout?

Here, I'm using the code in my homecontroller.php -

public function __construct()
{
    $this->middleware('auth');
}

Now, I want to customize the "auth" middleware. But I don't find the location.

Shoukhin
  • 151
  • 2
  • 12
  • 3
    Possible duplicate of [How to change the redirect url when logging out?](https://stackoverflow.com/questions/29797433/how-to-change-the-redirect-url-when-logging-out) – Jigar Shah Aug 15 '17 at 11:31

2 Answers2

0

class : app/Http/Controllers/Auth/AuthController.php

Add below property to the class

protected $redirectAfterLogout = 'auth/new_redirect';
syntaxe
  • 112
  • 4
-1

I found it in vendor\laravel\framework\src\Illuminate\Foundation\Auth\AuthenticatesUsers.php

It is not recommended to edit anything in your vendor's folder because if you move your app to a different server or upgrade the framework to a new version. But if you're fine with that risk, just change the redirect path to your preferred URL.

 /**
 * Log the user out of the application.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function logout(Request $request)
{
    $this->guard()->logout();
    $request->session()->invalidate();
    return redirect('/');
}

You can also override it via AuthController (recommended). Just add this property:

protected $redirectAfterLogout = 'auth/login';
sylenix
  • 161
  • 2
  • 8