简体   繁体   English

身份验证后如何继续将用户转到请求的页面?

[英]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.

相关问题 PHP Zend身份验证-如何告诉Zend用户已通过身份验证 - PHP Zend Authentication - How can I tell Zend the user is authenticated 用户访问页面后如何使其过期? - How can I make a page expire after user visit it? 用户下载文件后如何显示Thankyou页面? - How can I display a Thankyou page after user downloads file? 如何创建一个可以由经过身份验证的用户和未经身份验证的用户访问的页面 - How to create a page that can be accessed by either authenticated users and non authenticated 用户转到另一个页面后如何销毁会话? - How can I destroy the session after the user go to another page? 在请求 SQL 结果后,如何对它们进行排序? - How can I order SQL results after they have been requested? Tymon JWT:我如何通过他的 id 从经过身份验证的用户向另一个用户进行身份验证? - Tymon JWT: how can I authenticate from authenticated user with another user via his id? 如何缓存当前经过身份验证的用户? - How do I cache the current authenticated user? 包含的php页面可以显示有关请求页面的任何信息吗? 如果没有,我该如何发送? - Does the included php page can show any info about the requested page? If no, how can I send any? 在Facebook用户授予权限后才能继续刷新页面以继续 - Forced to refresh page after a facebook user grants permissions in order to continue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM