From 9d94d0c72753cfbdf8c21b65a1f2d0ff39ddc52c Mon Sep 17 00:00:00 2001 From: lixueping Date: Wed, 6 Nov 2024 14:09:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=94=99=E8=AF=AF=E6=8D=95=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/guard-core-v4/src/MFA/core/email.tsx | 8 ++++++-- packages/guard-core-v4/src/MFA/core/sms.tsx | 8 ++++++-- packages/guard-core-v4/src/SendCode/SendCodeByPhone.tsx | 8 ++++++-- .../src/TenantPortalSelect/InputEmailCode/index.tsx | 8 ++++++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/packages/guard-core-v4/src/MFA/core/email.tsx b/packages/guard-core-v4/src/MFA/core/email.tsx index d607458e7..defe1707c 100644 --- a/packages/guard-core-v4/src/MFA/core/email.tsx +++ b/packages/guard-core-v4/src/MFA/core/email.tsx @@ -152,8 +152,12 @@ export const VerifyMFAEmail: React.FC = ({ message.error(t('login.sendCodeTimeout')) return false } - const errorMessage = JSON.parse(e.message) - message.error(errorMessage.message) + try { + const errorMessage = JSON.parse(e.message) + message.error(errorMessage.message) + } catch (_) { + message.error(e) + } return false } } diff --git a/packages/guard-core-v4/src/MFA/core/sms.tsx b/packages/guard-core-v4/src/MFA/core/sms.tsx index dcec2b057..4d1992e5d 100644 --- a/packages/guard-core-v4/src/MFA/core/sms.tsx +++ b/packages/guard-core-v4/src/MFA/core/sms.tsx @@ -246,8 +246,12 @@ export const VerifyMFASms: React.FC = ({ message.error(t('login.sendCodeTimeout')) return false } - const errorMessage = JSON.parse(e.message) - message.error(errorMessage.message) + try { + const errorMessage = JSON.parse(e.message) + message.error(errorMessage.message) + } catch (_) { + message.error(e) + } return false } } diff --git a/packages/guard-core-v4/src/SendCode/SendCodeByPhone.tsx b/packages/guard-core-v4/src/SendCode/SendCodeByPhone.tsx index 2b7f24840..36ee2e796 100644 --- a/packages/guard-core-v4/src/SendCode/SendCodeByPhone.tsx +++ b/packages/guard-core-v4/src/SendCode/SendCodeByPhone.tsx @@ -103,8 +103,12 @@ export const SendCodeByPhone: React.FC = props => { error } } - const { message: msg } = JSON.parse(error.message) - message.error(msg) + try { + const errorMessage = JSON.parse(error.message) + message.error(errorMessage.message) + } catch (_) { + message.error(error) + } return { status: false, error diff --git a/packages/guard-core-v4/src/TenantPortalSelect/InputEmailCode/index.tsx b/packages/guard-core-v4/src/TenantPortalSelect/InputEmailCode/index.tsx index 9abc4692d..981e42cc1 100644 --- a/packages/guard-core-v4/src/TenantPortalSelect/InputEmailCode/index.tsx +++ b/packages/guard-core-v4/src/TenantPortalSelect/InputEmailCode/index.tsx @@ -55,8 +55,12 @@ export const InputEmailCode: React.FC = ({ message.error(t('login.sendCodeTimeout')) return false } - const errorMessage = JSON.parse(e.message) - message.error(errorMessage.message) + try { + const errorMessage = JSON.parse(e.message) + message.error(errorMessage.message) + } catch (_) { + message.error(e) + } return false } }