sbr
04/04/2022, 7:09 PMwithoutAuthRequired
?
My logic is-
- /login
should be shown only if a user is not authenticated
- If a user is authenticated then /login
should redirect to /home
- /home
should be shown only if a user is authenticated
- If a user is not authenticated then /home
should redirect to /login
The last two points can use withAuthRequired
. How can the first two points be implemented?Needle
04/04/2022, 7:09 PM/title
command!
We have solved your problem?
Click the button below to archive it.Needle
04/04/2022, 7:10 PMwithoutAuthRequired
?Needle
04/04/2022, 7:10 PMsaeris
04/05/2022, 1:15 AMwithMiddlewareAuthRequired
function I contributed, copy the code from withAuthRequired
and modify it to redirect the user if a session is detected. Good candidate for your own PR as well.
Can cut out most of the cookie validation logic too I believe, just need to check to see if the cookies are set to begin with and possibly whether they are expired.
If the auth and refresh cookies exist, and they aren't expired, bounce the user.
If auth is expired, try refreshing it and then bounce.
If both are invalid/non-existent, allow the request to continue to the requested routeNeedle
04/05/2022, 1:15 AMsbr
04/06/2022, 5:19 AM