Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upLogged 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.