简体   繁体   English

Laravel 5.8 Auth脚手架redirectTo不起作用

[英]Laravel 5.8 Auth scaffolding redirectTo doesn't work

Using the default laravel auth scaffolding in 5.8 in the LoginController theres a variable : 在LoginController中使用5.8中的默认laravel auth脚手架有一个变量:

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

I have changed this to '/dashboard' yet it still redirects me to home. 我已经将其更改为“/ dashboard”,但它仍然将我重定向到了家。

How do I fix that? 我该如何解决这个问题?

I bumped into this problem back when I started learning it. 当我开始学习它时,我回到了这个问题。

Go to ' app/Http/Middleware/RedirectIfAuthinticated.php '. 转到' app/Http/Middleware/RedirectIfAuthinticated.php '。 Check that file. 检查该文件。 I reckon in your case it has something like return redirect('/home'); 我认为在你的情况下它有类似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. 如果存在重定向路径,那么它将优先于$ redirectTo属性。 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. 例如,如果登录用户的类别是客户,则将他发送到其他地方等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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