Fix a bug in guard regarding deprecated method isLoggedIn
This commit is contained in:
parent
56a877461d
commit
01b5d26b62
|
@ -1 +1 @@
|
|||
Subproject commit e6b2f41c8c858f860ed4bf48d7a31e5a04d7a088
|
||||
Subproject commit d9a2f3b0eee5348accb910e304006ccb38804775
|
|
@ -24,23 +24,17 @@ export class AdminDashboardGuard implements CanActivate, CanActivateChild {
|
|||
}
|
||||
|
||||
check(path: string, alias: string): Observable<boolean> | boolean {
|
||||
if (Session.isLoggedIn()) {
|
||||
return zip(
|
||||
this.userManagementService.getUserInfo(false)
|
||||
,this.stakeholderService.getStakeholder(alias)
|
||||
).pipe(take(1),map(res =>{
|
||||
return res[0] && res[1] && (Session.isPortalAdministrator(res[0]) ||
|
||||
Session.isCurator(res[1].type, res[0]) || Session.isManager(res[1].type, res[1].alias, res[0]));
|
||||
}),tap(authorized => {
|
||||
if(!authorized){
|
||||
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_ADMIN, 'redirectUrl':path}});
|
||||
}
|
||||
}));
|
||||
|
||||
} else {
|
||||
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, 'redirectUrl':path}});
|
||||
return false;
|
||||
}
|
||||
return zip(
|
||||
this.userManagementService.getUserInfo(false)
|
||||
,this.stakeholderService.getStakeholder(alias)
|
||||
).pipe(take(1),map(res =>{
|
||||
return res[0] && res[1] && (Session.isPortalAdministrator(res[0]) ||
|
||||
Session.isCurator(res[1].type, res[0]) || Session.isManager(res[1].type, res[1].alias, res[0]));
|
||||
}),tap(authorized => {
|
||||
if(!authorized){
|
||||
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_ADMIN, 'redirectUrl':path}});
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||
|
|
Loading…
Reference in New Issue