The Users.Login
and Users.Logout
methods redirect the user to the homepage, but should redirect the user to the page from which they came. E.g., if the user is trying to edit a bout and redirected to the login page, they should be redirected back to that bout to resume editing.
Add a hidden return_to
field in the login form with a URL to redirect back to. Links to log in or out should include a return_to
parameter. Then parse return_to
from the URL or form (depending on situation) and redirect there.
Set a return_to
cookie in middleware when redirecting to log in. Use JavaScript (?) to set cookies when clicking the log in or log out links. There might be another way to do this aside from using JavaScript; if not Option 1 is a better choice.
After core functionality is implemented. This is a convenience feature.
Sourcehut does a great job with this and uses Option 1.