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

support something similar to how return_to works for regular controllers #450

Closed
simon-nystrom opened this issue May 19, 2024 · 3 comments
Closed

Comments

@simon-nystrom
Copy link

When attempting to access an authenticated resource such as one like this:

  ash_authentication_live_session :authentication_required,
    on_mount: {MyApp.LiveUserAuth, :live_user_required} do
    live "/protected", SomeView
  end

You successfully get redirected to the the sign in page, but once you sign in successfully there seems to be no easy way to figure out where you came from, and thus no easy way to redirect back to where your authentication failed

It would be great if there was an easy way to send the user back to where they were redirected from

@ahacking
Copy link
Contributor

FYI. There is an example of doing this in the Ash Real-world app here: https://github.com/team-alembic/realworld/blob/main/lib/realworld_web/controllers/auth_controller.ex

A lot can be learned looking through that app.

@simon-nystrom
Copy link
Author

Thanks ahacking, I realize now it wasn't apparent that I was referring to trying to get the same behaviour for LiveViews, what you've linked is actually what caused me to word this issue "similar to how return_to works for regular controllers"

@ahacking
Copy link
Contributor

ahacking commented Aug 2, 2024

I have actually documented an approach in #484 that might be helpful until I have some time to work up a proper PR.

@jimsynz jimsynz closed this as completed Nov 6, 2024
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

No branches or pull requests

3 participants