web: improve error display when only {'detail'} is returned

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-09-02 19:55:37 +02:00
parent 7fea20375f
commit 92ce5f0931
2 changed files with 8 additions and 2 deletions

View File

@ -61,4 +61,4 @@ export const DEFAULT_CONFIG = new Configuration({
],
});
console.debug(`authentik: version ${VERSION}`);
console.debug(`authentik(early): version ${VERSION}`);

View File

@ -224,9 +224,15 @@ export class Form<T> extends LitElement {
throw ex;
})
.catch((ex: Error) => {
let msg = ex.toString();
// Only change the message when we have `detail`.
// Everything else is handled in the form.
if (ex instanceof APIError && "detail" in ex.response) {
msg = ex.response.detail;
}
// error is local or not from rest_framework
showMessage({
message: ex.toString(),
message: msg,
level: MessageLevel.error,
});
// rethrow the error so the form doesn't close