mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4665] [ADF] - Application is refreshed when you have two instances of application opened (#4849)
* refactoring getValueFromToken and fix user token refresh * refactoring getValueFromToken and fix user token refresh * refactoring getValueFromToken and fix user token refres * fix unit test
This commit is contained in:
@@ -56,19 +56,19 @@ export class AuthGuardSsoRoleService implements CanActivate {
|
||||
}
|
||||
|
||||
getRealmRoles(): string[] {
|
||||
const access = this.getValueFromToken<any>('realm_access');
|
||||
const access = this.jwtHelperService.getValueFromLocalAccessToken<any>('realm_access');
|
||||
const roles = access ? access['roles'] : [];
|
||||
return roles;
|
||||
}
|
||||
|
||||
getClientRoles(client: string): string[] {
|
||||
const clientRole = this.getValueFromToken<any>('resource_access')[client];
|
||||
const clientRole = this.jwtHelperService.getValueFromLocalAccessToken<any>('resource_access')[client];
|
||||
const roles = clientRole ? clientRole['roles'] : [];
|
||||
return roles;
|
||||
}
|
||||
|
||||
getAccessToken(): string {
|
||||
return this.storageService.getItem('access_token');
|
||||
return this.storageService.getItem(JwtHelperService.USER_ACCESS_TOKEN);
|
||||
}
|
||||
|
||||
hasRealmRole(role: string): boolean {
|
||||
@@ -104,14 +104,4 @@ export class AuthGuardSsoRoleService implements CanActivate {
|
||||
}
|
||||
return hasRole;
|
||||
}
|
||||
|
||||
getValueFromToken<T>(key: string): T {
|
||||
let value;
|
||||
const accessToken = this.getAccessToken();
|
||||
if (accessToken) {
|
||||
const tokenPayload = this.jwtHelperService.decodeToken(accessToken);
|
||||
value = tokenPayload[key];
|
||||
}
|
||||
return <T> value;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user