-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Logged in user will not be detected if refreshing in AuthGuarded route #2774
Comments
Implemented the following solution, will submit a PR if in agreement with strategy. @Awk34 auth.service.ts:
auth-guard.service.ts:
|
Definitely an improvement, this works pretty good for me. Thanks! |
Cool solution @blindstuff (#2774 (comment)) How about taking it even a little bit further like: auth.service.ts:
auth-guard.service.ts:
and for example in the admin module
|
Good idea @albert-92 I had solved this in my implementation by editing canActivate. Either route seems to do well, I preferred to keep them separate, but am open to either.
|
A user that has sucesfully logged on will not be detected as logged in if the site is refreshed inside an AuthGuarded route.
Steps to reproduce bug:
Cause:
Router is evaluating the CanActivate function before the constructor has retrevied the user from the Token
AuthGuard triggered
AuthGuard Cancels Navigation
This part of the constructor finishes running and get the user too late.
Click on another authguarded route after this will work. Bug only occurs while refreshing.
The text was updated successfully, but these errors were encountered: