简体   繁体   中英

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. This is Chrome trying to help you and/or your users.

A POST request is by definition an operation that alters data. Executing a POST a second time, unintentionally, may mess things up. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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