From 5a1d0f077a772b76015d1d4be0e7f7f23e57d0bb Mon Sep 17 00:00:00 2001 From: Jason Chuang Date: Tue, 21 Apr 2026 00:41:03 +0800 Subject: [PATCH] show messsage if iamsmart user already existing --- src/auth/index.js | 9 +++++++++ src/pages/iAmSmart/RegistryCallback/index.js | 12 +++++++++--- src/translations/en.json | 6 +++--- src/translations/zh-CN.json | 6 +++--- src/translations/zh-HK.json | 4 ++-- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/auth/index.js b/src/auth/index.js index 9ff9474..1a6a8e9 100644 --- a/src/auth/index.js +++ b/src/auth/index.js @@ -151,6 +151,15 @@ export const SetupAxiosInterceptors = () => { async (error) => { // const { config, response: { status } } = error const status = error.response?.status + const reqUrl = error.config?.url || '' + // iAM Smart registration: HKID already linked — caller must show /iamsmart/pleaseLogin (not refresh/logout) + if ( + status === 401 && + reqUrl.includes('/smart/getProfile') && + error.response?.data?.exception === 'msg: account created' + ) { + return Promise.reject(error) + } if (status === 401 && error.config?.url !== apiPath + REFRESH_TOKEN) { // Make a request to refresh the access token const refreshToken = localStorage.getItem('refreshToken'); diff --git a/src/pages/iAmSmart/RegistryCallback/index.js b/src/pages/iAmSmart/RegistryCallback/index.js index 6d9f279..0f91a86 100644 --- a/src/pages/iAmSmart/RegistryCallback/index.js +++ b/src/pages/iAmSmart/RegistryCallback/index.js @@ -19,6 +19,12 @@ const Index = () => { getPrfile(); }, []); + function isIAmSmartAccountAlreadyRegistered(error) { + const ex = error?.response?.data?.exception + const httpStatus = error?.response?.status + return httpStatus === 409 || ex === 'msg: account created' + } + function getPrfile(){ let params = new URLSearchParams(window.location.search) @@ -38,9 +44,9 @@ const Index = () => { }, onError:(error)=>{ console.log(error); - if(error?.response?.data?.exception == "msg: account created"){ - navigate("/iamsmart/pleaseLogin", { state: {registryMethod:"iAmSmart"}} ); - }else{ + if (isIAmSmartAccountAlreadyRegistered(error)) { + navigate("/iamsmart/pleaseLogin", { state: { registryMethod: "iAmSmart" } }); + } else { window.location.assign("/register"); } } diff --git a/src/translations/en.json b/src/translations/en.json index c9851b0..6f14a44 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -185,9 +185,9 @@ "loginErrorMessage6":"User account not found", "loginErrorMessage7":"System is under maintenance, please check back later.", - "pleaseLloginMessage1":"User account already created", - "pleaseLloginMessage2":"You are our existing user, please login to your account.", - "pleaseLloginMessage3":"Go to Login page", + "pleaseLloginMessage1":"Account already registered", + "pleaseLloginMessage2":"The identity you verified with iAM Smart is already linked to an existing PNSPS account. Please go to the login page and sign in—there is no need to register again.", + "pleaseLloginMessage3":"Go to login page", "loginSuccessMessage1":"User account link up success", "loginSuccessMessage2":"You are our existing user and successfully linked your existing account.
From now on, you can log in through \"iAM Smart\".", diff --git a/src/translations/zh-CN.json b/src/translations/zh-CN.json index c7ed11e..b834b09 100644 --- a/src/translations/zh-CN.json +++ b/src/translations/zh-CN.json @@ -221,9 +221,9 @@ "loginErrorMessage6":"找不到用户帐户", "loginErrorMessage7":"系统正在维护中,请稍后再查看", - "pleaseLloginMessage1":"帐户已建立", - "pleaseLloginMessage2":"你是我们的现有用户,请登入你的帐户。", - "pleaseLloginMessage3":"前往登入页面", + "pleaseLloginMessage1":"账户已注册", + "pleaseLloginMessage2":"您通过「智方便」核实的身份已用于注册本系统账户。请前往登录页面登录,无需重新开户。", + "pleaseLloginMessage3":"前往登录页面", "loginSuccessMessage1":"成功连结现有帐户", "loginSuccessMessage2":"你是我们的现有客户,已成功连结现有帐户。
以后可以透过「智方便」登入。", diff --git a/src/translations/zh-HK.json b/src/translations/zh-HK.json index 5bb2472..0be353a 100644 --- a/src/translations/zh-HK.json +++ b/src/translations/zh-HK.json @@ -222,8 +222,8 @@ "loginErrorMessage6":"找不到用戶帳戶", "loginErrorMessage7":"系統正在維護中,請稍後再查看", - "pleaseLloginMessage1":"帳戶已建立", - "pleaseLloginMessage2":"你是我們的現有用戶,請登入你的帳戶。", + "pleaseLloginMessage1":"帳戶已註冊", + "pleaseLloginMessage2":"你透過「智方便」核實的身分已用於註冊本系統帳戶。請前往登入頁面登入,無須重新開戶。", "pleaseLloginMessage3":"前往登入頁面", "loginSuccessMessage1":"成功連結現有帳戶",