in my app, I'm resolving the user from the BE after login. I would like to navigate to certain init page base on the role of the user. I have tried doing this with a can activate guard, but because guards are being calculated before resolvers, my user is undefined and the app is stuck. (important to mention, I'm using ngrx to manage state and so my user is saved to the state). Is there any way I could check the role of my user in the can activate guard and somehow await the UserResolver ?
Asked
Active
Viewed 305 times
0
-
When you get the user data from your LoginComponent, just do a switch case based on the user's role, and then, navigate to the wanted page – Emilien Jul 20 '20 at 10:18
-
It is a bit more complicated, because I'm using ssr in my app, in my login component I'm only getting the accessToken and refreshToken and then im resolving the user in the routing module. (My user has a base64 profile picture and ssr didn't like it). – יובל צרפתי Jul 20 '20 at 10:24
1 Answers
0
Yes you can, check out Todd Motto's blog Preloading ngrx store with Route Guards. Instead of waiting on the resolver, you can wait on state.

timdeschryver
- 14,415
- 1
- 19
- 32