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: signin page stuck on loading when refresh token valid but access token expired (#30675)

yyh160b4d194bad
diff --git a/web/app/signin/normal-form.tsx b/web/app/signin/normal-form.tsx
index bf4d80326b6..be0feea6c15 100644
--- a/web/app/signin/normal-form.tsx
+++ b/web/app/signin/normal-form.tsx
@@ -28,7 +28,8 @@ const NormalForm = () => {
const message = decodeURIComponent(searchParams.get('message') || '')
const invite_token = decodeURIComponent(searchParams.get('invite_token') || '')
const [isInitCheckLoading, setInitCheckLoading] = useState(true)
- const isLoading = isCheckLoading || loginData?.logged_in || isInitCheckLoading
+ const [isRedirecting, setIsRedirecting] = useState(false)
+ const isLoading = isCheckLoading || isInitCheckLoading || isRedirecting
const { systemFeatures } = useGlobalPublicStore()
const [authType, updateAuthType] = useState<'code' | 'password'>('password')
const [showORLine, setShowORLine] = useState(false)
@@ -40,6 +41,7 @@ const NormalForm = () => {
const init = useCallback(async () => {
try {
if (isLoggedIn) {
+ setIsRedirecting(true)
const redirectUrl = resolvePostLoginRedirect(searchParams)
router.replace(redirectUrl || '/apps')
return
diff --git a/web/service/use-common.ts b/web/service/use-common.ts
index a1edb041c07..ca0845d95ae 100644
--- a/web/service/use-common.ts
+++ b/web/service/use-common.ts
@@ -221,13 +221,12 @@ export const useIsLogin = () => {
await get('/account/profile', {}, {
silent: true,
})
- }
- catch (e: any) {
- if (e.status === 401)
- return { logged_in: false }
return { logged_in: true }
}
- return { logged_in: true }
+ catch {
+ // Any error (401, 500, network error, etc.) means not logged in
+ return { logged_in: false }
+ }
},
})
}