diff --git a/web/app/(shareLayout)/webapp-signin/check-code/page.tsx b/web/app/(shareLayout)/webapp-signin/check-code/page.tsx index 72e3b7f2ea..afea9d668b 100644 --- a/web/app/(shareLayout)/webapp-signin/check-code/page.tsx +++ b/web/app/(shareLayout)/webapp-signin/check-code/page.tsx @@ -66,7 +66,9 @@ export default function CheckCode() { setIsLoading(true) const ret = await webAppEmailLoginWithCode({ email, code: encryptVerificationCode(code), token }) if (ret.result === 'success') { - setWebAppAccessToken(ret.data.access_token) + if (ret?.data?.access_token) { + setWebAppAccessToken(ret.data.access_token) + } const { access_token } = await fetchAccessToken({ appCode: appCode!, userId: embeddedUserId || undefined, 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 11aebe4a5b..e49559401d 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 @@ -82,7 +82,9 @@ export default function MailAndPasswordAuth({ isEmailSetup }: MailAndPasswordAut body: loginData, }) if (res.result === 'success') { - setWebAppAccessToken(res.data.access_token) + if (res?.data?.access_token) { + setWebAppAccessToken(res.data.access_token) + } const { access_token } = await fetchAccessToken({ appCode: appCode!, diff --git a/web/app/signin/components/mail-and-password-auth.tsx b/web/app/signin/components/mail-and-password-auth.tsx index 01ec4c74ed..92165bb65b 100644 --- a/web/app/signin/components/mail-and-password-auth.tsx +++ b/web/app/signin/components/mail-and-password-auth.tsx @@ -65,8 +65,10 @@ export default function MailAndPasswordAuth({ isInvite, isEmailSetup, allowRegis body: loginData, }) if (res.result === 'success') { - // Track login success event - setWebAppAccessToken(res.data.access_token) + if (res?.data?.access_token) { + // Track login success event + setWebAppAccessToken(res.data.access_token) + } trackEvent('user_login_success', { method: 'email_password', is_invite: isInvite, diff --git a/web/service/common.ts b/web/service/common.ts index 70211d10d3..3d9c05e75b 100644 --- a/web/service/common.ts +++ b/web/service/common.ts @@ -38,7 +38,7 @@ import { del, get, patch, post, put } from './base' type LoginSuccess = { result: 'success' - data: { access_token: string } + data?: { access_token?: string } } type LoginFail = { result: 'fail'