diff --git a/lib/core/src/lib/auth/guard/auth-guard-base.ts b/lib/core/src/lib/auth/guard/auth-guard-base.ts index 7727fe546c..caab7c4765 100644 --- a/lib/core/src/lib/auth/guard/auth-guard-base.ts +++ b/lib/core/src/lib/auth/guard/auth-guard-base.ts @@ -55,7 +55,11 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild { route: ActivatedRouteSnapshot, state: RouterStateSnapshot ): Observable | Promise | boolean | UrlTree { - if (this.authenticationService.isLoggedIn() && this.authenticationService.isOauth() && this.isLoginFragmentPresent()) { + if ( + this.authenticationService.isLoggedIn() && + this.authenticationService.isOauth() && + this.isLoginFragmentPresent() + ) { return this.redirectSSOSuccessURL(); } diff --git a/lib/core/src/lib/auth/services/authentication.service.ts b/lib/core/src/lib/auth/services/authentication.service.ts index 0aa1e00c04..e1980806e7 100644 --- a/lib/core/src/lib/auth/services/authentication.service.ts +++ b/lib/core/src/lib/auth/services/authentication.service.ts @@ -100,6 +100,7 @@ export class AuthenticationService implements AuthenticationServiceInterface, ee } getToken(): string { + debugger; if (this.isOauth()) { return this.oidcAuthenticationService.getToken(); } else { diff --git a/lib/core/src/lib/common/services/storage.service.ts b/lib/core/src/lib/common/services/storage.service.ts index e4daedd230..2aed655159 100644 --- a/lib/core/src/lib/common/services/storage.service.ts +++ b/lib/core/src/lib/common/services/storage.service.ts @@ -15,7 +15,13 @@ * limitations under the License. */ -import { Injectable } from '@angular/core'; +import { Inject, Injectable, InjectionToken, Optional } from '@angular/core'; + +export interface StorageServiceSettings { + storageType?: 'localStorage' | 'sessionStorage' | 'memoryStorage'; +} + +export const STORAGE_SERVICE_SETTINGS = new InjectionToken('STORAGE_SERVICE_SETTINGS'); @Injectable({ providedIn: 'root' @@ -24,6 +30,7 @@ export class StorageService { private memoryStore: { [key: string]: any } = {}; private readonly useLocalStorage: boolean = false; private _prefix: string = ''; + private storage?: Storage; get prefix() { return this._prefix; @@ -33,8 +40,28 @@ export class StorageService { this._prefix = prefix ? prefix + '_' : ''; } - constructor() { - this.useLocalStorage = this.storageAvailable('localStorage'); + constructor( + @Optional() + @Inject(STORAGE_SERVICE_SETTINGS) private settings?: StorageServiceSettings + ) { + if (this.settings) { + debugger; + switch (this.settings.storageType) { + case 'sessionStorage': + this.useLocalStorage = this.storageAvailable(this.settings.storageType); + this.storage = window['sessionStorage']; + break; + case 'memoryStorage': + this.useLocalStorage = false; + break; + default: + this.useLocalStorage = this.storageAvailable(this.settings.storageType); + this.storage = window['localStorage']; + } + } else { + this.useLocalStorage = this.storageAvailable('localStorage'); + this.storage = window['localStorage']; + } } /** @@ -45,7 +72,7 @@ export class StorageService { */ getItem(key: string): string | null { if (this.useLocalStorage) { - return localStorage.getItem(this.prefix + key); + return this.storage.getItem(this.prefix + key); } else { return Object.prototype.hasOwnProperty.call(this.memoryStore, this.prefix + key) ? this.memoryStore[this.prefix + key] : null; } @@ -59,7 +86,7 @@ export class StorageService { */ setItem(key: string, data: string) { if (this.useLocalStorage) { - localStorage.setItem(this.prefix + key, data); + this.storage.setItem(this.prefix + key, data); } else { this.memoryStore[this.prefix + key] = data.toString(); } @@ -68,7 +95,7 @@ export class StorageService { /** Removes all currently stored items. */ clear() { if (this.useLocalStorage) { - localStorage.clear(); + this.storage.clear(); } else { this.memoryStore = {}; } @@ -81,7 +108,7 @@ export class StorageService { */ removeItem(key: string) { if (this.useLocalStorage) { - localStorage.removeItem(`${this.prefix}` + key); + this.storage.removeItem(`${this.prefix}` + key); } else { delete this.memoryStore[this.prefix + key]; } @@ -95,7 +122,7 @@ export class StorageService { */ hasItem(key: string): boolean { if (this.useLocalStorage) { - return !!localStorage.getItem(this.prefix + key); + return !!this.storage.getItem(this.prefix + key); } else { return Object.prototype.hasOwnProperty.call(this.memoryStore, key); } diff --git a/lib/core/src/lib/common/services/user-preferences.service.ts b/lib/core/src/lib/common/services/user-preferences.service.ts index 57dd29ab9c..2c9a625ba3 100644 --- a/lib/core/src/lib/common/services/user-preferences.service.ts +++ b/lib/core/src/lib/common/services/user-preferences.service.ts @@ -114,6 +114,7 @@ export class UserPreferencesService { * @param value New value for the property */ set(property: string, value: any) { + console.trace(); if (!property) { return; } @@ -132,6 +133,7 @@ export class UserPreferencesService { * @param value New value for the property */ setWithoutStore(property: string, value: any) { + // debugger; if (!property) { return; } diff --git a/lib/core/src/lib/pipes/time-ago.pipe.ts b/lib/core/src/lib/pipes/time-ago.pipe.ts index 9119a18d6f..dc8c8907d0 100644 --- a/lib/core/src/lib/pipes/time-ago.pipe.ts +++ b/lib/core/src/lib/pipes/time-ago.pipe.ts @@ -38,8 +38,10 @@ export class TimeAgoPipe implements PipeTransform, OnDestroy { private onDestroy$ = new Subject(); - constructor(public userPreferenceService: UserPreferencesService, - public appConfig: AppConfigService) { + constructor( + public userPreferenceService: UserPreferencesService, + public appConfig: AppConfigService + ) { this.userPreferenceService .select(UserPreferenceValues.Locale) .pipe(takeUntil(this.onDestroy$)) diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts index 58900b44c4..cb68a14b4d 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts @@ -375,6 +375,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, } return form; } + return null; } @@ -396,8 +397,10 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, private refreshFormData() { this.form = this.parseForm(this.formCloudRepresentationJSON); - this.onFormLoaded(this.form); - this.onFormDataRefreshed(this.form); + if (this.form) { + this.onFormLoaded(this.form); + this.onFormDataRefreshed(this.form); + } } protected onFormLoaded(form: FormModel) {