I have a lazy loaded module with canActivate guard and after the lazily loaded module is loaded, somehow the page is made unauthenticated (say by logging in as a different role in different tab of same browser), so when we try to access previous lazily loaded module's components they are successfully accessed on previously loaded tab. Can anyone please explain why this happens or any other way to handle such scenario?
Note: I have more than one lazily loaded modules loaded on basis of user role, lazily loaded modules may have same one or more Child components
Code:
main-routing.module.ts
{
path: 'admin',
loadChildren: 'app/featureModules/admin/admin.module#AdminModule',
canActivate: [ AdminGuardService]
},{
path: 'staff',
loadChildren: 'app/featureModules/staff/staff.module#StaffModule',
canActivate: [ StaffGuardService]
}
In staff-routing.ts
{
path: '',
loadChildren: 'app/featureModules/property-details-view/property-details-view.module#PropertyDetailsViewModule'
}
In admin-routing.ts
{
path: '',
loadChildren: 'app/featureModules/property-details-view/property-details-view.module#PropertyDetailsViewModule'
}
StaffGuardService and AdminGuardService validates the role of user and allows the access to corresponding route.