简体   繁体   中英

Laravel 5.8 Auth scaffolding redirectTo doesn't work

Using the default laravel auth scaffolding in 5.8 in the LoginController theres a variable :

  /** * Where to redirect users after login. * * @var string */ 
  protected $redirectTo = '/home';

I have changed this to '/dashboard' yet it still redirects me to home.

How do I fix that?

I bumped into this problem back when I started learning it.

Go to ' app/Http/Middleware/RedirectIfAuthinticated.php '. Check that file. I reckon in your case it has something like return redirect('/home'); which should be changed to appropriate route.

If there is a redirection path there then it will have higher precedence over the $redirectTo property. You can use this function for custom logic also. For example, if the category of the logged in user is customer then send him to somewhere else etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM