From 35fea50077a16372de057d4800a0d170c7418e54 Mon Sep 17 00:00:00 2001 From: NFish Date: Thu, 29 May 2025 15:33:08 +0800 Subject: [PATCH] fix: add appCode to header X-App-Code --- web/app/(shareLayout)/webapp-signin/check-code/page.tsx | 2 +- .../webapp-signin/components/mail-and-password-auth.tsx | 2 +- web/app/(shareLayout)/webapp-signin/page.tsx | 2 +- web/app/components/share/utils.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/app/(shareLayout)/webapp-signin/check-code/page.tsx b/web/app/(shareLayout)/webapp-signin/check-code/page.tsx index 394de93400..0f0bad8919 100644 --- a/web/app/(shareLayout)/webapp-signin/check-code/page.tsx +++ b/web/app/(shareLayout)/webapp-signin/check-code/page.tsx @@ -59,7 +59,7 @@ export default function CheckCode() { const ret = await webAppEmailLoginWithCode({ email, code, token }) if (ret.result === 'success') { localStorage.setItem('webAppAccessToken', ret.data.access_token) - await checkOrSetAccessToken() + await checkOrSetAccessToken(appCode) router.replace(redirectUrl) } } diff --git a/web/app/(shareLayout)/webapp-signin/components/mail-and-password-auth.tsx b/web/app/(shareLayout)/webapp-signin/components/mail-and-password-auth.tsx index 1e5044b6ef..b07108b207 100644 --- a/web/app/(shareLayout)/webapp-signin/components/mail-and-password-auth.tsx +++ b/web/app/(shareLayout)/webapp-signin/components/mail-and-password-auth.tsx @@ -84,7 +84,7 @@ export default function MailAndPasswordAuth({ isEmailSetup }: MailAndPasswordAut }) if (res.result === 'success') { localStorage.setItem('webAppAccessToken', res.data.access_token) - await checkOrSetAccessToken() + await checkOrSetAccessToken(appCode) router.replace(redirectUrl) } else { diff --git a/web/app/(shareLayout)/webapp-signin/page.tsx b/web/app/(shareLayout)/webapp-signin/page.tsx index 73fb0e1f4b..a0855487b4 100644 --- a/web/app/(shareLayout)/webapp-signin/page.tsx +++ b/web/app/(shareLayout)/webapp-signin/page.tsx @@ -46,7 +46,7 @@ const WebSSOForm: FC = () => { const appCode = getAppCodeFromRedirectUrl() if (appCode && tokenFromUrl && redirectUrl) { localStorage.setItem('webAppAccessToken', tokenFromUrl) - await checkOrSetAccessToken() + await checkOrSetAccessToken(appCode) router.replace(redirectUrl) } })() diff --git a/web/app/components/share/utils.ts b/web/app/components/share/utils.ts index 91c3d9a6dc..741c4e873f 100644 --- a/web/app/components/share/utils.ts +++ b/web/app/components/share/utils.ts @@ -10,8 +10,8 @@ export const getInitialTokenV2 = (): Record => ({ version: 2, }) -export const checkOrSetAccessToken = async () => { - const sharedToken = globalThis.location.pathname.split('/').slice(-1)[0] +export const checkOrSetAccessToken = async (appCode?: string) => { + const sharedToken = appCode || globalThis.location.pathname.split('/').slice(-1)[0] const userId = (await getProcessedSystemVariablesFromUrlParams()).user_id const accessToken = localStorage.getItem('token') || JSON.stringify(getInitialTokenV2()) let accessTokenJson = getInitialTokenV2()