From 92ce5f0931d9db42e4b9c562b0a7657f08f3b001 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 2 Sep 2021 19:55:37 +0200 Subject: [PATCH] web: improve error display when only {'detail'} is returned Signed-off-by: Jens Langhammer --- web/src/api/Config.ts | 2 +- web/src/elements/forms/Form.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/web/src/api/Config.ts b/web/src/api/Config.ts index 25df2d6a9..a22432582 100644 --- a/web/src/api/Config.ts +++ b/web/src/api/Config.ts @@ -61,4 +61,4 @@ export const DEFAULT_CONFIG = new Configuration({ ], }); -console.debug(`authentik: version ${VERSION}`); +console.debug(`authentik(early): version ${VERSION}`); diff --git a/web/src/elements/forms/Form.ts b/web/src/elements/forms/Form.ts index 16b8a46cf..85cee382f 100644 --- a/web/src/elements/forms/Form.ts +++ b/web/src/elements/forms/Form.ts @@ -224,9 +224,15 @@ export class Form 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