Skip to content

Commit

Permalink
format errors from auth-jwt plugin similarly to other authentication …
Browse files Browse the repository at this point in the history
…errors (#6553)
  • Loading branch information
meirish authored Apr 9, 2019
1 parent b10dc70 commit 670f43e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions ui/app/components/auth-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default Component.extend(DEFAULTS, {

showLoading: or('isLoading', 'authenticate.isRunning', 'fetchMethods.isRunning', 'unwrapToken.isRunning'),

handleError(e) {
handleError(e, prefixMessage = true) {
this.set('loading', false);
if (!e.errors) {
return e;
Expand All @@ -184,7 +184,8 @@ export default Component.extend(DEFAULTS, {
}
return error;
});
this.set('error', `Authentication failed: ${errors.join('.')}`);
let message = prefixMessage ? 'Authentication failed: ' : '';
this.set('error', `${message}${errors.join('.')}`);
},

authenticate: task(function*(backendType, data) {
Expand Down Expand Up @@ -239,5 +240,12 @@ export default Component.extend(DEFAULTS, {
}
return this.authenticate.unlinked().perform(backend.type, data);
},
handleError(e) {
if (e) {
this.handleError(e, false);
} else {
this.set('error', null);
}
},
},
});
2 changes: 1 addition & 1 deletion ui/app/templates/components/auth-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
{{/if}}
{{#if (or (eq this.selectedAuthBackend.type "jwt") (eq this.selectedAuthBackend.type "oidc"))}}
<AuthJwt
@onError={{action (mut this.error)}}
@onError={{action "handleError"}}
@onLoading={{action (mut this.isLoading)}}
@onToken={{action (mut this.token)}}
@namespace={{this.namespace}}
Expand Down

0 comments on commit 670f43e

Please sign in to comment.