diff --git a/demo-shell-ng2/custom-translation/alfresco-login/i18n/en.json b/demo-shell-ng2/custom-translation/alfresco-login/i18n/en.json index e7e1d8223f..5982c16a33 100644 --- a/demo-shell-ng2/custom-translation/alfresco-login/i18n/en.json +++ b/demo-shell-ng2/custom-translation/alfresco-login/i18n/en.json @@ -15,7 +15,8 @@ "LOGIN-ERROR-PROVIDERS": "Providers cannot be undefined", "LOGIN-SUCCESS": "Login successful", "LOGIN-ERROR-CORS": "CORS exception, check your server configuration", - "LOGIN-ERROR-CSRF": "CSRF exception, set [disableCsrf]=\"true\" in alfresco-login component" + "LOGIN-ERROR-CSRF": "CSRF exception, set [disableCsrf]=\"true\" in alfresco-login component", + "LOGIN-ECM-LICENSE": "The ECM is in read-only mode" }, "BUTTON": { "LOGIN": "SIGN IN" diff --git a/demo-shell-ng2/custom-translation/alfresco-login/i18n/it.json b/demo-shell-ng2/custom-translation/alfresco-login/i18n/it.json index 5588ae39dd..b1c50a86bf 100644 --- a/demo-shell-ng2/custom-translation/alfresco-login/i18n/it.json +++ b/demo-shell-ng2/custom-translation/alfresco-login/i18n/it.json @@ -14,7 +14,8 @@ "LOGIN-ERROR-PROVIDERS": "Providers non può essere nullo", "LOGIN-SUCCESS": "Login effettuata con successo", "LOGIN-ERROR-CORS": "CORS exception, controlla le configurazioni del tuo server", - "LOGIN-ERROR-CSRF": "CSRF exception, set [disableCsrf]=\"true\" in alfresco-login component" + "LOGIN-ERROR-CSRF": "CSRF exception, set [disableCsrf]=\"true\" in alfresco-login component", + "LOGIN-ECM-LICENSE": "l'ECM e' in read-only mode" }, "BUTTON": { "LOGIN": "Accedi" diff --git a/ng2-components/ng2-alfresco-login/src/assets/authentication.service.mock.ts b/ng2-components/ng2-alfresco-login/src/assets/authentication.service.mock.ts index e51df930fc..97271742ce 100644 --- a/ng2-components/ng2-alfresco-login/src/assets/authentication.service.mock.ts +++ b/ng2-components/ng2-alfresco-login/src/assets/authentication.service.mock.ts @@ -39,7 +39,10 @@ export class AuthenticationMock /*extends AlfrescoAuthenticationService*/ { return Observable.throw({message: 'ERROR: Invalid CSRF-token', status: 403}); } - return Observable.throw('Fake server error'); + if (username === 'fake-username-ECM-access-error' && password === 'fake-password') { + return Observable.throw({message: 'ERROR: 00170728 Access Denied. The system is currently in read-only mode', status: 403}); + } + return Observable.throw('Fake server error'); } } diff --git a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts index b36d04eb0e..88742f8c12 100644 --- a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts +++ b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts @@ -310,6 +310,29 @@ describe('AlfrescoLogin', () => { expect(element.querySelector('#login-error').innerText).toEqual('LOGIN.MESSAGES.LOGIN-ERROR-CSRF'); }); + it('should return ECOM read-oly error when error occurs', () => { + component.providers = 'ECM'; + expect(component.success).toBe(false); + expect(component.error).toBe(false); + + usernameInput.value = 'fake-username-ECM-access-error'; + passwordInput.value = 'fake-password'; + + usernameInput.dispatchEvent(new Event('input')); + passwordInput.dispatchEvent(new Event('input')); + + fixture.detectChanges(); + + element.querySelector('button').click(); + + fixture.detectChanges(); + + expect(component.error).toBe(true); + expect(component.success).toBe(false); + expect(element.querySelector('#login-error')).toBeDefined(); + expect(element.querySelector('#login-error').innerText).toEqual('LOGIN.MESSAGES.LOGIN-ECM-LICENSE'); + }); + it('should emit onSuccess event after the login has succeeded', () => { spyOn(component.onSuccess, 'emit'); component.providers = 'ECM'; diff --git a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts index 05e2755115..789b4e794d 100644 --- a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts +++ b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts @@ -171,16 +171,21 @@ export class AlfrescoLoginComponent implements OnInit { */ private displayErrorMessage(err: any): void { if (err.error && err.error.crossDomain && err.error.message.indexOf('the network is offline, Origin is not allowed by' + - ' Access-Control-Allow-Origin') > 0) { + ' Access-Control-Allow-Origin') !== -1) { this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CORS'; return; } - if (err.status === 403 && err.message.indexOf('Invalid CSRF-token') > 0) { + if (err.status === 403 && err.message.indexOf('Invalid CSRF-token') !== -1) { this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CSRF'; return; } + if (err.status === 403 && err.message.indexOf('The system is currently in read-only mode') !== -1) { + this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ECM-LICENSE'; + return; + } + this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CREDENTIALS'; } diff --git a/ng2-components/ng2-alfresco-login/src/i18n/en.json b/ng2-components/ng2-alfresco-login/src/i18n/en.json index e7e1d8223f..5982c16a33 100644 --- a/ng2-components/ng2-alfresco-login/src/i18n/en.json +++ b/ng2-components/ng2-alfresco-login/src/i18n/en.json @@ -15,7 +15,8 @@ "LOGIN-ERROR-PROVIDERS": "Providers cannot be undefined", "LOGIN-SUCCESS": "Login successful", "LOGIN-ERROR-CORS": "CORS exception, check your server configuration", - "LOGIN-ERROR-CSRF": "CSRF exception, set [disableCsrf]=\"true\" in alfresco-login component" + "LOGIN-ERROR-CSRF": "CSRF exception, set [disableCsrf]=\"true\" in alfresco-login component", + "LOGIN-ECM-LICENSE": "The ECM is in read-only mode" }, "BUTTON": { "LOGIN": "SIGN IN" diff --git a/ng2-components/ng2-alfresco-login/src/i18n/it.json b/ng2-components/ng2-alfresco-login/src/i18n/it.json index 5588ae39dd..b1c50a86bf 100644 --- a/ng2-components/ng2-alfresco-login/src/i18n/it.json +++ b/ng2-components/ng2-alfresco-login/src/i18n/it.json @@ -14,7 +14,8 @@ "LOGIN-ERROR-PROVIDERS": "Providers non può essere nullo", "LOGIN-SUCCESS": "Login effettuata con successo", "LOGIN-ERROR-CORS": "CORS exception, controlla le configurazioni del tuo server", - "LOGIN-ERROR-CSRF": "CSRF exception, set [disableCsrf]=\"true\" in alfresco-login component" + "LOGIN-ERROR-CSRF": "CSRF exception, set [disableCsrf]=\"true\" in alfresco-login component", + "LOGIN-ECM-LICENSE": "l'ECM e' in read-only mode" }, "BUTTON": { "LOGIN": "Accedi"