[英]How can i continue the user to the requested page after authenticated?
I was wondering how can i continue the user requested page after authenticated with laravel 5.2
? 我想知道在使用
laravel 5.2
进行身份验证后如何继续用户请求的页面? Do i need to set a session or laravel has something to do this? 我需要设置一个会话,还是laravel可以执行此操作?
Example: I am not registered yet. 示例:我尚未注册。 I am looking for a product.
我正在寻找产品。 I click
"Order Now"
button. 我单击
"Order Now"
按钮。 Then i go to login/register
page. 然后,我进入
login/register
页面。 After getting authenticated i go to the order page with the product that i want to order. 获得身份验证后,我将转到要订购的产品的订购页面。
Sorry for my newbie question. 对不起,我的新手问题。 May i can get some help on how to make this process right.
我可以就如何正确执行此过程获得一些帮助。 Or maybe i get some references for this.
也许我对此有一些参考。 thanks.
谢谢。
You can use the intended URL method in Laravel. 您可以在Laravel中使用预期的URL方法。
Eg: 例如:
public function authenticate()
{
if(Auth::attempt(['email'=> $email, 'password'=>$password])
{
return redirect()->intended('dashboard');
}
}
In the above example, the user will be redirected to the 'dashboard' after login if there's no intended URL. 在上面的示例中,如果没有预期的URL,则用户将在登录后重定向到“仪表板”。 Else, he will be redirected to the last page after login.
否则,他将在登录后重定向到最后一页。
Intended url is the page from which the user is being redirected to login. 预期的url是将用户重定向到登录页面。
Read more here: https://laravel.com/docs/5.2/authentication#authenticating-users 在此处阅读更多信息: https : //laravel.com/docs/5.2/authentication#authenticating-users
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.