Fix a bug in guards regarding deprecated method isLoggedIn

This commit is contained in:
Konstantinos Triantafyllou 2022-04-13 13:50:55 +03:00
parent e6b2f41c8c
commit d9a2f3b0ee
2 changed files with 13 additions and 21 deletions

View File

@ -22,23 +22,18 @@ export class LoginGuard implements CanActivate, CanLoad, CanActivateChild {
}
check(path: string): Observable<boolean> | boolean {
if (Session.isLoggedIn()) {
return this.userManagementService.getUserInfo(false).pipe(map(user => {
return user !== null;
}),tap(isLoggedIn => {
if(!isLoggedIn) {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_LOGIN,
'redirectUrl': path
}
});
}
}));
} else {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, 'redirectUrl':path}});
return false;
}
return this.userManagementService.getUserInfo(false).pipe(map(user => {
return user !== null;
}),tap(isLoggedIn => {
if(!isLoggedIn) {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_LOGIN,
'redirectUrl': path
}
});
}
}));
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {

View File

@ -91,10 +91,7 @@ export class ResultPreviewComponent implements OnInit, OnChanges {
getPID() {
return Identifier.getResultPIDFromIdentifiers(this.result.identifiers);
}
get isLoggedIn(): boolean {
return Session.isLoggedIn();
}
public initBeforeTitle() {
if(this.result.resultType && this.result.resultType !== 'dataprovider') {
this.type = this.getTypeName(this.result.resultType);