diff --git a/lib/core/services/alfresco-api.service.ts b/lib/core/services/alfresco-api.service.ts index adc5d7fe69..c0ec11fdc7 100644 --- a/lib/core/services/alfresco-api.service.ts +++ b/lib/core/services/alfresco-api.service.ts @@ -134,6 +134,7 @@ export class AlfrescoApiService { contextRoot: this.appConfig.get(AppConfigValues.CONTEXTROOTECM), disableCsrf: this.appConfig.get(AppConfigValues.DISABLECSRF), withCredentials: this.appConfig.get(AppConfigValues.AUTH_WITH_CREDENTIALS, false), + domainPrefix : this.appConfig.get(AppConfigValues.STORAGE_PREFIX), oauth2: oauth }); diff --git a/lib/core/services/auth-guard.service.ts b/lib/core/services/auth-guard.service.ts index bbe9b2fbb8..2fe90b31b0 100644 --- a/lib/core/services/auth-guard.service.ts +++ b/lib/core/services/auth-guard.service.ts @@ -43,15 +43,15 @@ export class AuthGuard extends AuthGuardBase { } ticketChange(event: StorageEvent) { - if (event.key === 'ticket-ECM' && event.newValue !== event.oldValue) { + if (event.key.includes('ticket-ECM') && event.newValue !== event.oldValue) { this.ticketChangeRedirect(event, 'ECM'); } - if (event.key === 'ticket-BPM' && event.newValue !== event.oldValue) { + if (event.key.includes('ticket-BPM') && event.newValue !== event.oldValue) { this.ticketChangeRedirect(event, 'BPM'); } - if (event.key === JwtHelperService.USER_ACCESS_TOKEN && + if (event.key.includes(JwtHelperService.USER_ACCESS_TOKEN) && this.jwtHelperService.getValueFromToken(event.newValue, JwtHelperService.USER_PREFERRED_USERNAME) !== this.jwtHelperService.getValueFromToken(event.oldValue, JwtHelperService.USER_PREFERRED_USERNAME)) { this.ticketChangeRedirect(event, 'ALL'); diff --git a/lib/core/services/authentication.service.ts b/lib/core/services/authentication.service.ts index 31ac5304ee..7c5cdf4dae 100644 --- a/lib/core/services/authentication.service.ts +++ b/lib/core/services/authentication.service.ts @@ -26,6 +26,7 @@ import { UserRepresentation } from '@alfresco/js-api'; import { map, catchError, tap } from 'rxjs/operators'; import { HttpHeaders } from '@angular/common/http'; import { JwtHelperService } from './jwt-helper.service'; +import { StorageService } from './storage.service'; const REMEMBER_ME_COOKIE_KEY = 'ALFRESCO_REMEMBER_ME'; const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30; @@ -43,6 +44,7 @@ export class AuthenticationService { constructor( private appConfig: AppConfigService, + private storageService: StorageService, private alfrescoApi: AlfrescoApiService, private cookie: CookieService, private logService: LogService) { @@ -292,7 +294,7 @@ export class AuthenticationService { * @returns Auth token string */ getToken(): string { - return localStorage.getItem(JwtHelperService.USER_ACCESS_TOKEN); + return this.storageService.getItem(JwtHelperService.USER_ACCESS_TOKEN); } /** diff --git a/lib/core/services/jwt-helper.service.ts b/lib/core/services/jwt-helper.service.ts index 667780323d..4f9cca7f42 100644 --- a/lib/core/services/jwt-helper.service.ts +++ b/lib/core/services/jwt-helper.service.ts @@ -16,6 +16,7 @@ */ import { Injectable } from '@angular/core'; +import { StorageService } from './storage.service'; @Injectable({ providedIn: 'root' @@ -31,7 +32,7 @@ export class JwtHelperService { static RESOURCE_ACCESS = 'resource_access'; static USER_PREFERRED_USERNAME = 'preferred_username'; - constructor() { + constructor(private storageService: StorageService) { } /** @@ -89,12 +90,12 @@ export class JwtHelperService { * @returns access token */ getAccessToken(): string { - return localStorage.getItem(JwtHelperService.USER_ACCESS_TOKEN); + return this.storageService.getItem(JwtHelperService.USER_ACCESS_TOKEN); } /** * Gets a named value from the user access token. - * @param key accessToken + * @param accessToken your SSO access token where the value is encode * @param key Key name of the field to retrieve * @returns Value from the token */