sublinks / sublinks-frontend

MIT License
17 stars 5 forks source link

Redirect user after login #154

Open kgilles opened 3 months ago

kgilles commented 3 months ago

If a logged out user tries to access a restricted page, such as the post-creation page, they will instead be directed to the login page. When this happens we want to keep track of the page the user attempted to access, and direct them there automatically after they successfully log in.

For example

  1. Logged out user tries to navigate to /p to create a post
  2. They're instead taken to /login
  3. The user logs in
  4. They're automatically taken to /p
chasingtheflow commented 2 months ago

Did you envision this being resolved by adding middleware or do you want to add the checks directly into the protected hoc routes (forget the exact name of the component)?

kgilles commented 2 months ago

Did you envision this being resolved by adding middleware or do you want to add the checks directly into the protected hoc routes (forget the exact name of the component)?

I believe we can add the referred path as a query parameter to the login page URL via the restricted page component.