简体   繁体   English

Ruby on Rails:防止用户登录成功后返回登录表单

[英]Ruby on Rails: Prevent users back to login form after logged in successfully

Ok.好的。 I have a login page.我有一个登录页面。 After I entered the email and password correctly and it redirects to me to the user profile.在我正确输入电子邮件和密码后,它会重定向到我的用户个人资料。 When I hit the browser back button, it also redirects to the user profile which works fine.当我点击浏览器后退按钮时,它也会重定向到工作正常的用户配置文件。 But the problem raises when let's say if I enter the email or password wrongly, it says "email/password incorrectly", and I enter second time correctly it redirects me to the user profile, but when I hit the browser back button, the page will show "Comfirm form resubmission".但是当假设我输入的电子邮件或密码错误时,问题就出现了,它说“电子邮件/密码错误”,我第二次正确输入它会将我重定向到用户配置文件,但是当我点击浏览器后退按钮时,页面将显示“确认表单重新提交”。 This doesn't make sense.这没有意义。

"Confirm form re-submission" has nothing to do with Rails. “确认表单重新提交”与Rails 无关。 This is Chrome trying to help you and/or your users.这是 Chrome 试图帮助您和/或您的用户。

A POST request is by definition an operation that alters data.根据定义,POST 请求是更改数据的操作。 Executing a POST a second time, unintentionally, may mess things up.无意中再次执行 POST 可能会把事情搞砸。 Imagine paying twice for the same product.想象一下,为同一种产品支付两次费用。

As Rustam A. Gasanov pointed out in his comment, you really shouldn't bother much with the behavior of the back button in this case.正如 Rustam A. Gasanov 在他的评论中指出的那样,在这种情况下,您真的不应该为后退按钮的行为而烦恼。

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

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