From b9f95e9147afafe703a7548350f2023ded6d204c Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 3 Dec 2025 14:50:31 +0800 Subject: [PATCH] perf: Improve Form Validation on Third-Party Authentication Platforms --- .../src/views/system/authentication/CasEditor.vue | 15 +++++++++++---- .../views/system/authentication/LdapEditor.vue | 15 +++++++++++---- .../views/system/authentication/Oauth2Editor.vue | 15 +++++++++++---- .../views/system/authentication/OidcEditor.vue | 15 +++++++++++---- 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/frontend/src/views/system/authentication/CasEditor.vue b/frontend/src/views/system/authentication/CasEditor.vue index 8fd40bbe..584b194a 100644 --- a/frontend/src/views/system/authentication/CasEditor.vue +++ b/frontend/src/views/system/authentication/CasEditor.vue @@ -128,8 +128,8 @@ const submitForm = async (formEl: FormInstance | undefined) => { name: 'cas', } const method = id.value - ? request.put('/system/authentication', data) - : request.post('/system/authentication', data) + ? request.put('/system/authentication', data, { requestOptions: { silent: true } }) + : request.post('/system/authentication', data, { requestOptions: { silent: true } }) showLoading() method .then((res) => { @@ -138,9 +138,16 @@ const submitForm = async (formEl: FormInstance | undefined) => { emits('saved') reset() } - closeLoading() }) - .catch(() => { + .catch((e: any) => { + if ( + e.message?.startsWith('sqlbot_authentication_connect_error') || + e.response?.data?.startsWith('sqlbot_authentication_connect_error') + ) { + ElMessage.error(t('ds.connection_failed')) + } + }) + .finally(() => { closeLoading() }) } diff --git a/frontend/src/views/system/authentication/LdapEditor.vue b/frontend/src/views/system/authentication/LdapEditor.vue index ec1a49cf..47bb4a18 100644 --- a/frontend/src/views/system/authentication/LdapEditor.vue +++ b/frontend/src/views/system/authentication/LdapEditor.vue @@ -119,8 +119,8 @@ const submitForm = async (formEl: FormInstance | undefined) => { name: 'ldap', } const method = id.value - ? request.put('/system/authentication', data) - : request.post('/system/authentication', data) + ? request.put('/system/authentication', data, { requestOptions: { silent: true } }) + : request.post('/system/authentication', data, { requestOptions: { silent: true } }) showLoading() method .then((res) => { @@ -129,9 +129,16 @@ const submitForm = async (formEl: FormInstance | undefined) => { emits('saved') reset() } - closeLoading() }) - .catch(() => { + .catch((e: any) => { + if ( + e.message?.startsWith('sqlbot_authentication_connect_error') || + e.response?.data?.startsWith('sqlbot_authentication_connect_error') + ) { + ElMessage.error(t('ds.connection_failed')) + } + }) + .finally(() => { closeLoading() }) } diff --git a/frontend/src/views/system/authentication/Oauth2Editor.vue b/frontend/src/views/system/authentication/Oauth2Editor.vue index f0575067..a09145cb 100644 --- a/frontend/src/views/system/authentication/Oauth2Editor.vue +++ b/frontend/src/views/system/authentication/Oauth2Editor.vue @@ -232,8 +232,8 @@ const submitForm = async (formEl: FormInstance | undefined) => { name: 'oauth2', } const method = id.value - ? request.put('/system/authentication', data) - : request.post('/system/authentication', data) + ? request.put('/system/authentication', data, { requestOptions: { silent: true } }) + : request.post('/system/authentication', data, { requestOptions: { silent: true } }) showLoading() method .then((res) => { @@ -242,9 +242,16 @@ const submitForm = async (formEl: FormInstance | undefined) => { emits('saved') reset() } - closeLoading() }) - .catch(() => { + .catch((e: any) => { + if ( + e.message?.startsWith('sqlbot_authentication_connect_error') || + e.response?.data?.startsWith('sqlbot_authentication_connect_error') + ) { + ElMessage.error(t('ds.connection_failed')) + } + }) + .finally(() => { closeLoading() }) } diff --git a/frontend/src/views/system/authentication/OidcEditor.vue b/frontend/src/views/system/authentication/OidcEditor.vue index bda0b504..27486834 100644 --- a/frontend/src/views/system/authentication/OidcEditor.vue +++ b/frontend/src/views/system/authentication/OidcEditor.vue @@ -174,8 +174,8 @@ const submitForm = async (formEl: FormInstance | undefined) => { name: 'oidc', } const method = id.value - ? request.put('/system/authentication', data) - : request.post('/system/authentication', data) + ? request.put('/system/authentication', data, { requestOptions: { silent: true } }) + : request.post('/system/authentication', data, { requestOptions: { silent: true } }) showLoading() method .then((res) => { @@ -184,9 +184,16 @@ const submitForm = async (formEl: FormInstance | undefined) => { emits('saved') reset() } - closeLoading() }) - .catch(() => { + .catch((e: any) => { + if ( + e.message?.startsWith('sqlbot_authentication_connect_error') || + e.response?.data?.startsWith('sqlbot_authentication_connect_error') + ) { + ElMessage.error(t('ds.connection_failed')) + } + }) + .finally(() => { closeLoading() }) }