Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: redirect after login (#30985)

Stephen Zhouf33b1a33324e
diff --git a/web/app/(shareLayout)/webapp-signin/check-code/page.tsx b/web/app/(shareLayout)/webapp-signin/check-code/page.tsx
index 72e3b7f2ead..afea9d668bf 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 11aebe4a5b6..e49559401d3 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 01ec4c74ed9..92165bb65bc 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 70211d10d3e..3d9c05e75b2 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'