登录后重定向laravel 7 [英] Redirect after login laravel 7
本文介绍了登录后重定向laravel 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在登录后将用户重定向到'/details'..但是它将我重定向到'/home'
I want to redirect the user after login to '/details'..but it redirect me to '/home'
LoginController.php
LoginController.php
public function authenticate(Request $request)
{
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
// Authentication passed...
return redirect()->intended('/details');
}
return redirect('/details');
}
RouterServiceProvider.php
RouterServiceProvider.php
public const HOME = '/details';
我已经尝试过了,但是还是做不到
I've tried this.but still can't do it
推荐答案
默认情况下,在您的LoginController中,只需替换
By default In your LoginController just replace
protected $redirectTo = '/home';
到
protected $redirectTo = '/details';
但是,如果您使用自己的身份验证,则可以这样使用
But if you use own authenticate so you use like this
public function authenticate(Request $request)
{
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
// Authentication passed...
return redirect($this->redirectPath());
//return redirect()->intended('/details');
}
return redirect($this->redirectPath());
}
这篇关于登录后重定向laravel 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文