#1443 improve license error - login component (#1494)

This commit is contained in:
Mario Romano
2017-01-17 16:19:25 +00:00
committed by Maurizio Vitale
parent 0fd45a2f88
commit 7ef954139c
7 changed files with 42 additions and 7 deletions

View File

@@ -15,7 +15,8 @@
"LOGIN-ERROR-PROVIDERS": "Providers cannot be undefined", "LOGIN-ERROR-PROVIDERS": "Providers cannot be undefined",
"LOGIN-SUCCESS": "Login successful", "LOGIN-SUCCESS": "Login successful",
"LOGIN-ERROR-CORS": "CORS exception, check your server configuration", "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": { "BUTTON": {
"LOGIN": "SIGN IN" "LOGIN": "SIGN IN"

View File

@@ -14,7 +14,8 @@
"LOGIN-ERROR-PROVIDERS": "Providers non può essere nullo", "LOGIN-ERROR-PROVIDERS": "Providers non può essere nullo",
"LOGIN-SUCCESS": "Login effettuata con successo", "LOGIN-SUCCESS": "Login effettuata con successo",
"LOGIN-ERROR-CORS": "CORS exception, controlla le configurazioni del tuo server", "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": { "BUTTON": {
"LOGIN": "Accedi" "LOGIN": "Accedi"

View File

@@ -39,7 +39,10 @@ export class AuthenticationMock /*extends AlfrescoAuthenticationService*/ {
return Observable.throw({message: 'ERROR: Invalid CSRF-token', status: 403}); 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');
} }
} }

View File

@@ -310,6 +310,29 @@ describe('AlfrescoLogin', () => {
expect(element.querySelector('#login-error').innerText).toEqual('LOGIN.MESSAGES.LOGIN-ERROR-CSRF'); 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', () => { it('should emit onSuccess event after the login has succeeded', () => {
spyOn(component.onSuccess, 'emit'); spyOn(component.onSuccess, 'emit');
component.providers = 'ECM'; component.providers = 'ECM';

View File

@@ -171,16 +171,21 @@ export class AlfrescoLoginComponent implements OnInit {
*/ */
private displayErrorMessage(err: any): void { private displayErrorMessage(err: any): void {
if (err.error && err.error.crossDomain && err.error.message.indexOf('the network is offline, Origin is not allowed by' + 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'; this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CORS';
return; 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'; this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CSRF';
return; 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'; this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CREDENTIALS';
} }

View File

@@ -15,7 +15,8 @@
"LOGIN-ERROR-PROVIDERS": "Providers cannot be undefined", "LOGIN-ERROR-PROVIDERS": "Providers cannot be undefined",
"LOGIN-SUCCESS": "Login successful", "LOGIN-SUCCESS": "Login successful",
"LOGIN-ERROR-CORS": "CORS exception, check your server configuration", "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": { "BUTTON": {
"LOGIN": "SIGN IN" "LOGIN": "SIGN IN"

View File

@@ -14,7 +14,8 @@
"LOGIN-ERROR-PROVIDERS": "Providers non può essere nullo", "LOGIN-ERROR-PROVIDERS": "Providers non può essere nullo",
"LOGIN-SUCCESS": "Login effettuata con successo", "LOGIN-SUCCESS": "Login effettuata con successo",
"LOGIN-ERROR-CORS": "CORS exception, controlla le configurazioni del tuo server", "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": { "BUTTON": {
"LOGIN": "Accedi" "LOGIN": "Accedi"