Recently, I've come across an interesting issue within my Angular application that consists of lazy-loaded modules.
In one specific module, there is a guard in place to verify if the user decoded from the JWT token is a system admin. If the user meets the criteria, they are granted access to the section; otherwise, they are redirected to the dashboard.
The peculiar aspect of this scenario is that it functions flawlessly only during the initial module load. Subsequent attempts to log out and login with a non-system admin user fail to trigger the CanLoad guard.
I attempted different strategies by implementing (CanActivate and CanActivateChild) interfaces within the same guard, placing the guard in both the app-routing.module.ts and feature-routing.module.ts files under the CanLoad, CanActivate, and CanActivateChild properties of the modules respectively.
However, the CanActivate and CanActivateChild methods never seem to get invoked, while the CanLoad method called from the app-routing.module.ts file executes just once.
Below you can find the content of the is-sys-adm.guard.ts file:
[guard code goes here...]
Here's a snippet of the app-routing.module.ts file:
[routing configuration goes here...]
And finally, a glimpse into the feature-routing.module.ts file:
[feature routing details go here...]
Despite trying different arrangements such as separating the guard into CanActivate, CanActivateChild, and CanLoad, the issue persists. Is there something crucial that I might be overlooking? Is this behavior intentional or should I consider submitting a bug report on the official repository?
Thank you to everyone willing to dedicate time to delve into this matter <3