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/webapp loop login (#21092)

NFishd7663159e975
diff --git a/web/app/(shareLayout)/layout.tsx b/web/app/(shareLayout)/layout.tsx
index 7de5d51edb5..78b88350096 100644
--- a/web/app/(shareLayout)/layout.tsx
+++ b/web/app/(shareLayout)/layout.tsx
@@ -19,7 +19,7 @@ const Layout: FC<{
const [isLoading, setIsLoading] = useState(true)
useEffect(() => {
(async () => {
- if (!systemFeatures.webapp_auth.enabled) {
+ if (!isGlobalPending && !systemFeatures.webapp_auth.enabled) {
setIsLoading(false)
return
}
@@ -37,7 +37,7 @@ const Layout: FC<{
setWebAppAccessMode(ret?.accessMode || AccessMode.PUBLIC)
setIsLoading(false)
})()
- }, [pathname, redirectUrl, setWebAppAccessMode])
+ }, [pathname, redirectUrl, setWebAppAccessMode, isGlobalPending, systemFeatures.webapp_auth.enabled])
if (isLoading || isGlobalPending) {
return <div className='flex h-full w-full items-center justify-center'>
<Loading />
diff --git a/web/service/base.ts b/web/service/base.ts
index ba398c07a6d..5242f15b80a 100644
--- a/web/service/base.ts
+++ b/web/service/base.ts
@@ -408,7 +408,7 @@ export const ssePost = async (
if (data.code === 'web_sso_auth_required') {
removeAccessToken()
- requiredWebSSOLogin()
+ requiredWebSSOLogin(data.message, 401)
}
if (data.code === 'unauthorized') {
@@ -492,7 +492,7 @@ export const request = async<T>(url: string, options = {}, otherOptions?: IOther
}
if (code === 'web_sso_auth_required') {
removeAccessToken()
- requiredWebSSOLogin()
+ requiredWebSSOLogin(message, 401)
return Promise.reject(err)
}
if (code === 'unauthorized_and_force_logout') {