Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom redirect locations #239

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

StevenClontz
Copy link
Contributor

@StevenClontz StevenClontz commented Dec 12, 2024

This PR extends the behavior of save_passwordless_redirect_location! to support saving custom URLs, and uses it to support implementing redirect_to parameter on the #new action. Example usage:

<%= link_to "Sign in", users_sign_in_path(redirect_to: request.url) %>

Otherwise, I don't believe there's a solution for developers to manually set a redirect location, other than something like session[redirect_session_key(User)] = params[:redirect_to] directly (which I currently have running as a before_action on session#new).

@StevenClontz StevenClontz marked this pull request as ready for review December 12, 2024 22:34
@mikker
Copy link
Owner

mikker commented Dec 17, 2024

Interesting! Not saying this is bad – would config.success_redirect_path suffice? Or do you specifically want to set it to different things depending on context/page or something like that?

@StevenClontz
Copy link
Contributor Author

StevenClontz commented Dec 17, 2024

Or do you specifically want to set it to different things depending on context/page or something like that?

Exactly. Feedback on my app was that users would click my sign in button, enter their code, and then have trouble navigating back to the page they were at when they originally tried to log in. So now my buttons have redirect_to=CURRENT_URL so the sign in route knows where to set the redirect session key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants