I have an angular app which should whether redirect to /route1 or to /route2 based on the user role. The thing is that keycloak must have a single route to redirect to after logging in (which in my case is route1) and this is how I have solved the routing issue:
I have this in ngOnInit of the component that gets loaded when the user is redirected to /route1:
All this does is redirect the user to /route2 if their role is role2, otherwise nothing happens.
The issue is that the isUserInRole causes an error when I try to run the unit test:
This is what the unit test looks like: