Login dialog shows error for Safari with Private Window mode (#1172)

* #958 new StorageService service

abstraction around ‘Storage’ to allow switching to in-memory store
whenever ‘localStorage’ is not available (i.e. private/incognito modes,
etc.)

* fix unit tests

* update unit tests

- disable incorrect auth tests (core)
- simplify widget visibility tests (activiti-form)

* fix unit tests
This commit is contained in:
Denys Vuika
2016-11-30 11:32:16 +00:00
committed by Eugenio Romano
parent 94dad585b1
commit da70a72bba
33 changed files with 494 additions and 414 deletions

View File

@@ -21,7 +21,8 @@ import { Router } from '@angular/router';
import {
AlfrescoTranslationService,
AlfrescoAuthenticationService,
AlfrescoSettingsService
AlfrescoSettingsService,
StorageService
} from 'ng2-alfresco-core';
declare var document: any;
@@ -40,7 +41,8 @@ export class AppComponent {
constructor(public auth: AlfrescoAuthenticationService,
public router: Router,
public alfrescoSettingsService: AlfrescoSettingsService,
private translate: AlfrescoTranslationService) {
private translate: AlfrescoTranslationService,
private storage: StorageService) {
this.setEcmHost();
this.setBpmHost();
this.setProvider();
@@ -103,26 +105,26 @@ export class AppComponent {
}
private setEcmHost() {
if (localStorage.getItem(`ecmHost`)) {
this.alfrescoSettingsService.ecmHost = localStorage.getItem(`ecmHost`);
this.ecmHost = localStorage.getItem(`ecmHost`);
if (this.storage.hasItem(`ecmHost`)) {
this.alfrescoSettingsService.ecmHost = this.storage.getItem(`ecmHost`);
this.ecmHost = this.storage.getItem(`ecmHost`);
} else {
this.alfrescoSettingsService.ecmHost = this.ecmHost;
}
}
private setBpmHost() {
if (localStorage.getItem(`bpmHost`)) {
this.alfrescoSettingsService.bpmHost = localStorage.getItem(`bpmHost`);
this.bpmHost = localStorage.getItem(`bpmHost`);
if (this.storage.hasItem(`bpmHost`)) {
this.alfrescoSettingsService.bpmHost = this.storage.getItem(`bpmHost`);
this.bpmHost = this.storage.getItem(`bpmHost`);
} else {
this.alfrescoSettingsService.bpmHost = this.bpmHost;
}
}
private setProvider() {
if (localStorage.getItem(`providers`)) {
this.alfrescoSettingsService.setProviders(localStorage.getItem(`providers`));
if (this.storage.hasItem(`providers`)) {
this.alfrescoSettingsService.setProviders(this.storage.getItem(`providers`));
}
}
}

View File

@@ -18,6 +18,7 @@
import { Component, ViewChild, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Validators } from '@angular/forms';
import { StorageService } from 'ng2-alfresco-core';
declare let __moduleName: string;
@@ -40,7 +41,7 @@ export class LoginDemoComponent implements OnInit {
isECM: boolean = true;
isBPM: boolean = false;
constructor(public router: Router) {
constructor(public router: Router, private storage: StorageService) {
this.customValidation = {
username: ['', Validators.compose([Validators.required, Validators.minLength(4)])],
password: ['', Validators.required]
@@ -52,8 +53,8 @@ export class LoginDemoComponent implements OnInit {
this.alfrescologin.addCustomValidationError('username', 'minlength', 'LOGIN.MESSAGES.USERNAME-MIN');
this.alfrescologin.addCustomValidationError('password', 'required', 'LOGIN.MESSAGES.PASSWORD-REQUIRED');
if (localStorage.getItem('providers')) {
this.providers = localStorage.getItem('providers');
if (this.storage.hasItem('providers')) {
this.providers = this.storage.getItem('providers');
}
this.setProviders();
@@ -91,7 +92,7 @@ export class LoginDemoComponent implements OnInit {
this.providers = '';
}
localStorage.setItem('providers', this.providers);
this.storage.setItem('providers', this.providers);
}
toggleBPM(checked) {
@@ -105,7 +106,7 @@ export class LoginDemoComponent implements OnInit {
this.providers = '';
}
localStorage.setItem('providers', this.providers);
this.storage.setItem('providers', this.providers);
}
toggleCSRF() {

View File

@@ -16,9 +16,7 @@
*/
import { Component } from '@angular/core';
import {
AlfrescoSettingsService
} from 'ng2-alfresco-core';
import { AlfrescoSettingsService, StorageService } from 'ng2-alfresco-core';
declare let __moduleName: string;
@@ -33,7 +31,8 @@ export class SettingComponent {
ecmHost: string;
bpmHost: string;
constructor(public alfrescoSettingsService: AlfrescoSettingsService) {
constructor(public alfrescoSettingsService: AlfrescoSettingsService,
private storage: StorageService) {
this.ecmHost = this.alfrescoSettingsService.ecmHost;
this.bpmHost = this.alfrescoSettingsService.bpmHost;
}
@@ -42,14 +41,14 @@ export class SettingComponent {
console.log((<HTMLInputElement>event.target).value);
this.ecmHost = (<HTMLInputElement>event.target).value;
this.alfrescoSettingsService.ecmHost = this.ecmHost;
localStorage.setItem(`ecmHost`, this.ecmHost);
this.storage.setItem(`ecmHost`, this.ecmHost);
}
public onChangeBPMHost(event: KeyboardEvent): void {
console.log((<HTMLInputElement>event.target).value);
this.bpmHost = (<HTMLInputElement>event.target).value;
this.alfrescoSettingsService.bpmHost = this.bpmHost;
localStorage.setItem(`bpmHost`, this.bpmHost);
this.storage.setItem(`bpmHost`, this.bpmHost);
}
}