Fix login when there is an error
This commit is contained in:
parent
b60e5f38da
commit
c9d6d155c3
|
@ -56,13 +56,11 @@ export class LoginComponent extends FormReactive implements OnInit {
|
||||||
this.authService.login(username, password).subscribe(
|
this.authService.login(username, password).subscribe(
|
||||||
result => this.router.navigate(['/videos/list']),
|
result => this.router.navigate(['/videos/list']),
|
||||||
|
|
||||||
error => {
|
err => {
|
||||||
console.error(error.json)
|
if (err.message === 'invalid_grant') {
|
||||||
|
|
||||||
if (error.json.error === 'invalid_grant') {
|
|
||||||
this.error = 'Credentials are invalid.'
|
this.error = 'Credentials are invalid.'
|
||||||
} else {
|
} else {
|
||||||
this.error = `${error.json.error}: ${error.json.error_description}`
|
this.error = `${err.body.error_description}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -54,11 +54,13 @@ export class RestExtractor {
|
||||||
|
|
||||||
const errorObj = {
|
const errorObj = {
|
||||||
message: errorMessage,
|
message: errorMessage,
|
||||||
status: undefined
|
status: undefined,
|
||||||
|
body: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err.status) {
|
if (err.status) {
|
||||||
errorObj.status = err.status
|
errorObj.status = err.status
|
||||||
|
errorObj.body = err.error
|
||||||
}
|
}
|
||||||
|
|
||||||
return Observable.throw(errorObj)
|
return Observable.throw(errorObj)
|
||||||
|
|
Loading…
Reference in New Issue