From c9d6d155c397d0da0cb2d50064264fc1716f0501 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 15 Sep 2017 12:26:02 +0200 Subject: [PATCH] Fix login when there is an error --- client/src/app/login/login.component.ts | 8 +++----- client/src/app/shared/rest/rest-extractor.service.ts | 4 +++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts index 77703a80c..32dc9e36f 100644 --- a/client/src/app/login/login.component.ts +++ b/client/src/app/login/login.component.ts @@ -56,13 +56,11 @@ export class LoginComponent extends FormReactive implements OnInit { this.authService.login(username, password).subscribe( result => this.router.navigate(['/videos/list']), - error => { - console.error(error.json) - - if (error.json.error === 'invalid_grant') { + err => { + if (err.message === 'invalid_grant') { this.error = 'Credentials are invalid.' } else { - this.error = `${error.json.error}: ${error.json.error_description}` + this.error = `${err.body.error_description}` } } ) diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts index 62c600d25..aafc9723e 100644 --- a/client/src/app/shared/rest/rest-extractor.service.ts +++ b/client/src/app/shared/rest/rest-extractor.service.ts @@ -54,11 +54,13 @@ export class RestExtractor { const errorObj = { message: errorMessage, - status: undefined + status: undefined, + body: undefined } if (err.status) { errorObj.status = err.status + errorObj.body = err.error } return Observable.throw(errorObj) -- 2.41.0