Redirect on successful authentication
This seems like a trivial issue but I can't seem to figure out how to do it. Suppose:
1. A user clicks the account button in the navbar but is currently logged out.
2. Ash authentication helpers redirect them to
/sign-in
.
3. They log in successfully.
How can I prevent the user from being redirected to /
and instead redirect them to /account
which the user was originally trying to access? More generally, if a user is trying to access a protected resources (e.g. /post/:post_id
which they own), how can I redirect them to that same URL as well upon successful login? Thanks so much in advance!2 Replies
That logic is in your auth controller
And there are some open issues that talk about a redirect plug for putting the user back to where they were
Perfect, thanks! I ended up doing a hybrid between the suggested ReturnTo plug in that issue, and an automatic redirect if there's an existing
return_to
key in the session, for OAuth apps (like Google) to also redirect on success, since they just redirect to the default base URI