73 backend remember me #90
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added remember me functionality for login. I decided not to use the cookies library since it would have required for us to create our own cookie and handle the remember me sessions by ourselves and logout the user after the set time period. I think it was better to use the JTW token from nextauth (which we already use). I had to modify the maxAge setting which handles how long until an idle session expires and is no longer valid. Since you cannot directly edit the change the maxAge on every reload of the session in options.ts. I had to dynamically pass in a dynamicMaxAge from router.ts to options.ts. It compares the current time with the expiration time (30 days or 1 day) to check how long the MaxAge has until it expires the session.
Issues
#73
Screenshots
N/A
Test
In order to test, I left console.logs that are useful for testing the session expiration times and that every value that holds the expiration date or expiration time is consistent in the JWT token, session, and nextAuth options.ts maxAge.
I will delete the console.logs once the pr is reviewd!
Possible Downsides
Since we are relying entirely on the nextAuth JWT token, if there is a fixed default behavior that we are unaware, it may cause issues. So far I have not seen any, but it may be hard to test in the future.
Additional Documentations