简体   繁体   English

登录后将用户返回到原始页面(rails会话mgmt)

[英]Return user to original page after logging in (rails session mgmt)

I'm looking for some general guidance as to how to return a user back to the original page they were viewing after trying to log-in. 我正在寻找有关如何在尝试登录后将用户返回到他们正在查看的原始页面的一些常规指导。

The way I have the site setup now is that if a user visits the Store page, for example, and then clicks the login button in the upper right, the user is returned to the default landing page. 我现在进行网站设置的方式是,例如,如果用户访问“商店”页面,然后单击右上角的登录按钮,则该用户将返回到默认登录页面。

Any help would be greatly appreciated! 任何帮助将不胜感激!

There are two ways how to do it: 有两种方法可以做到这一点:

  • either pass the current url as a param to the login link 可以将当前网址作为参数传递给登录链接
  • or check the request object for the referrer and if it's from your own site redirect back 或检查引荐来源网址的请求对象,如果它来自您自己的网站,请重定向回

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

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