use original error message for CORS/offline state in login (#1790)

* use original error message for CORS/offline state in login

* fix tests
This commit is contained in:
Denys Vuika 2017-03-30 19:26:28 +01:00 committed by Eugenio Romano
parent 2651ec46d6
commit 5a692f28f5
2 changed files with 3 additions and 4 deletions

View File

@ -294,7 +294,7 @@ describe('AlfrescoLogin', () => {
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-ERROR-CORS');
expect(element.querySelector('#login-error').innerText).toEqual('ERROR: the network is offline, Origin is not allowed by Access-Control-Allow-Origin');
});
it('should return CSRF error when server CSRF error occurs', () => {

View File

@ -179,9 +179,8 @@ export class AlfrescoLoginComponent implements OnInit {
* Check and display the right error message in the UI
*/
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') !== -1) {
this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CORS';
if (err.error && err.error.crossDomain && err.error.message.indexOf('Access-Control-Allow-Origin') !== -1) {
this.errorMsg = err.error.message;
return;
}