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.

refactor: convert webapp auth type if/elif to match/case (#30001) (#34782)

dataCenter430ce68f2cdc66a
diff --git a/api/controllers/web/passport.py b/api/controllers/web/passport.py
index 6a2e0b65fb8..66082893b81 100644
--- a/api/controllers/web/passport.py
+++ b/api/controllers/web/passport.py
@@ -138,12 +138,15 @@ def exchange_token_for_existing_web_user(app_code: str, enterprise_user_decoded:
if not app_model or app_model.status != "normal" or not app_model.enable_site:
raise NotFound()
- if auth_type == WebAppAuthType.PUBLIC:
- return _exchange_for_public_app_token(app_model, site, enterprise_user_decoded)
- elif auth_type == WebAppAuthType.EXTERNAL and user_auth_type != "external":
- raise WebAppAuthRequiredError("Please login as external user.")
- elif auth_type == WebAppAuthType.INTERNAL and user_auth_type != "internal":
- raise WebAppAuthRequiredError("Please login as internal user.")
+ match auth_type:
+ case WebAppAuthType.PUBLIC:
+ return _exchange_for_public_app_token(app_model, site, enterprise_user_decoded)
+ case WebAppAuthType.EXTERNAL:
+ if user_auth_type != "external":
+ raise WebAppAuthRequiredError("Please login as external user.")
+ case WebAppAuthType.INTERNAL:
+ if user_auth_type != "internal":
+ raise WebAppAuthRequiredError("Please login as internal user.")
end_user = None
if end_user_id: