mirror of
https://github.com/langgenius/dify.git
synced 2026-03-14 13:51:33 +08:00
fix: centralize access_mode validation and support sso_verified
- Add ALLOWED_ACCESS_MODES constant to centralize valid access modes - Include 'sso_verified' in validation to fix app duplication errors - Update error message to dynamically list all allowed modes - Refactor for maintainability: single source of truth for access modes This fixes the issue where apps with access_mode='sso_verified' could not be duplicated because the validation in update_app_access_mode() was missing this mode, even though it was documented in WebAppSettings model.
This commit is contained in:
parent
9e2b28c950
commit
23c75c7ec7
@ -4,6 +4,8 @@ from pydantic import BaseModel, Field
|
||||
|
||||
from services.enterprise.base import EnterpriseRequest
|
||||
|
||||
ALLOWED_ACCESS_MODES = ["public", "private", "private_all", "sso_verified"]
|
||||
|
||||
|
||||
class WebAppSettings(BaseModel):
|
||||
access_mode: str = Field(
|
||||
@ -123,8 +125,8 @@ class EnterpriseService:
|
||||
def update_app_access_mode(cls, app_id: str, access_mode: str):
|
||||
if not app_id:
|
||||
raise ValueError("app_id must be provided.")
|
||||
if access_mode not in ["public", "private", "private_all"]:
|
||||
raise ValueError("access_mode must be either 'public', 'private', or 'private_all'")
|
||||
if access_mode not in ALLOWED_ACCESS_MODES:
|
||||
raise ValueError(f"access_mode must be one of: {', '.join(ALLOWED_ACCESS_MODES)}")
|
||||
|
||||
data = {"appId": app_id, "accessMode": access_mode}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user