diff --git a/api/controllers/web/app.py b/api/controllers/web/app.py index bb4486bd91..d53d2ec994 100644 --- a/api/controllers/web/app.py +++ b/api/controllers/web/app.py @@ -46,11 +46,20 @@ class AppMeta(WebApiResource): class AppAccessMode(Resource): def get(self): parser = reqparse.RequestParser() - parser.add_argument("appId", type=str, required=True, location="args") + parser.add_argument("appId", type=str, required=False, location="args") + parser.add_argument("appCode", type=str, required=False, location="args") args = parser.parse_args() - app_id = args["appId"] - res = EnterpriseService.WebAppAuth.get_app_access_mode_by_id(app_id) + app_id = args.get("appId") + app_code = args.get("appCode") + + if not app_id and not app_code: + return {"error": "Missing app_id or app_code in query"}, 400 + + if app_id: + res = EnterpriseService.WebAppAuth.get_app_access_mode_by_id(app_id) + else: + res = EnterpriseService.WebAppAuth.get_app_access_mode_by_code(app_code) return {"accessMode": res.access_mode} diff --git a/web/app/(shareLayout)/layout.tsx b/web/app/(shareLayout)/layout.tsx index 8db336a17d..7de5d51edb 100644 --- a/web/app/(shareLayout)/layout.tsx +++ b/web/app/(shareLayout)/layout.tsx @@ -12,12 +12,18 @@ const Layout: FC<{ }> = ({ children }) => { const isGlobalPending = useGlobalPublicStore(s => s.isGlobalPending) const setWebAppAccessMode = useGlobalPublicStore(s => s.setWebAppAccessMode) + const systemFeatures = useGlobalPublicStore(s => s.systemFeatures) const pathname = usePathname() const searchParams = useSearchParams() const redirectUrl = searchParams.get('redirect_url') const [isLoading, setIsLoading] = useState(true) useEffect(() => { (async () => { + if (!systemFeatures.webapp_auth.enabled) { + setIsLoading(false) + return + } + let appCode: string | null = null if (redirectUrl) appCode = redirectUrl?.split('/').pop() || null