I have the conditional navigation based on customers role in the system. Something like this:
this.GetQuickStartStatus()
.subscribe(data => {
if(data.isActive){
this.storageService.Store('isQuick', "true");
}
else{
this.storageService.Store('isQuick', "false");
}
if(this.storageService.Retrieve("Role") === "user"){
console.log("package");
this.router.navigate(['/packages']);
}
if(this.storageService.Retrieve("Role") === "subscriber" && this.storageService.Retrieve("isQuick") === "false"){
console.log("quickstart");
this.router.navigate(['/quickstart']);
}
console.log("nothing");
this.router.navigate(['']);
}, (error) => {
console.log(error);
});
I log with the new user which should redirect to packages page since users role is "user. I get his in the console:
auth.service.ts:156 package
auth.service.ts:164 nothing
The meaning condition gets hit, but doesn't do anything aka router doesn't navigate to the requested page. I checked all conditions are met and all values are stored in localstorage. Why would router.navigate ignore redirection?
Routing module for packages:
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'packages', component: PackageComponent, canActivate: [AuthGuardService] },
{ path: 'receipt', component: PackageReceiptComponent, canActivate: [AuthGuardService, RoleSubscriberGuardService] },
{ path: 'receipt/:token', component: PackageReceiptComponent, canActivate: [AuthGuardService, RoleSubscriberGuardService]}
])
],
exports: [RouterModule]
})
export class PackageRoutingModule { }
else