Fix login when there is an error
authorChocobozzz <florian.bigard@gmail.com>
Fri, 15 Sep 2017 10:26:02 +0000 (12:26 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Fri, 15 Sep 2017 10:26:02 +0000 (12:26 +0200)
client/src/app/login/login.component.ts
client/src/app/shared/rest/rest-extractor.service.ts

index 77703a80c11b78636d3b5f9897560d5d9df1c51c..32dc9e36fed6769cef52db6006906e0ac0079981 100644 (file)
@@ -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}`
         }
       }
     )
index 62c600d25c3355ac95f5d988c3614b04359ee712..aafc9723ecac0028ed2537059982d17a9cd8709e 100644 (file)
@@ -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)