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

(feat) return path to original page #120

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

melmathari
Copy link

Return to path not stored when redirecting to login

Problem

When a user navigates to a protected route (e.g. /ads) while logged out, they get redirected to the login page but after logging in they end up at the home page (/) instead of their original destination.

Solution

Added maybe_store_return_to() to the redirect_authenticated function in RedirectController to store the return path in the session before redirecting to login.

Changes

  • Modified lib/algora_web/controllers/redirect_controller.ex to store return path

Testing

  1. Log out
  2. Navigate to /ads
  3. Get redirected to login page
  4. Log in
  5. Verify you get redirected back to /ads

The rest of the return_to flow was already properly implemented in:

  • LiveView routes via redirect_require_login
  • Login links in layouts
  • GitHub OAuth flow
  • Login callback handling

/claim #101

@CLAassistant
Copy link

CLAassistant commented Nov 24, 2024

CLA assistant check
All committers have signed the CLA.

@lastcanal
Copy link
Collaborator

Hi @melmathari, I am getting some syntax errors when I try to run your code; your latest commit includes a Javascript style comment deliminator, happens to the best of us!

Also, because you don't appear to be assigning uri to the socket anywhere, you will most likely get a KeyError when these code paths are exercised.

@zcesur zcesur marked this pull request as draft December 12, 2024 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants