-
Notifications
You must be signed in to change notification settings - Fork 2
Add a middleware layer, handle optimistic auth check on basic routes #76
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
Conversation
jhodapp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great Zach, thank you. A few things line to have a look at.
|
Clicking around a bit more than I did earlier. This might be a little premature. Reverting to draft for now |
Co-authored-by: Jim Hodapp <james.hodapp@gmail.com>
…h-store from localStorage
ec7284f to
466e086
Compare
…er initiatlization
jhodapp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, works as expected.
There is a newly exposed bug from moving to localStorage where the coaching_session_id contained in the URL vs the one in the AuthStore are used differently on the coaching session page and becomes evident when you try and open the same coaching session URL on a new tab of the same browser. But this isn't your fault, it's just a bug outside the scope of this PR.
Description
NextJS has a cool middleware feature we can leverage.
If I'm logged in and try to visit the login index page, redirect me to the dashboard. If I'm logged out and I try to access /dashboard or /coaching-session/... route, redirect me to the login index page.
This is not meant to be an all-encompassing route protection system. Just a simple "optimistic' light weight check against the cookie set by our login/logout API.
This does log a user out if their session expires from the backend.
Screenshots / Videos Showing UI Changes (if applicable)
Testing Strategy
describe how you or someone else can test and verify the changes
Concerns
Exposes bug #79 by the use of localStorage but not responsible for the bug.