Przeglądaj źródła

Merge pull request #5576 from open-webui/dev

fix: WEBUI_AUTH=False not working issue
Timothy Jaeryang Baek 7 miesięcy temu
rodzic
commit
f47dffe6e1
1 zmienionych plików z 13 dodań i 8 usunięć
  1. 13 8
      backend/open_webui/apps/webui/routers/auths.py

+ 13 - 8
backend/open_webui/apps/webui/routers/auths.py

@@ -188,14 +188,19 @@ async def signin(request: Request, response: Response, form_data: SigninForm):
 
 @router.post("/signup", response_model=SigninResponse)
 async def signup(request: Request, response: Response, form_data: SignupForm):
-    if (
-        not request.app.state.config.ENABLE_SIGNUP
-        or not request.app.state.config.ENABLE_LOGIN_FORM
-        or not WEBUI_AUTH
-    ):
-        raise HTTPException(
-            status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.ACCESS_PROHIBITED
-        )
+    if WEBUI_AUTH:
+        if (
+            not request.app.state.config.ENABLE_SIGNUP
+            or not request.app.state.config.ENABLE_LOGIN_FORM
+        ):
+            raise HTTPException(
+                status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.ACCESS_PROHIBITED
+            )
+    else:
+        if Users.get_num_users() != 0:
+            raise HTTPException(
+                status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.ACCESS_PROHIBITED
+            )
 
     if not validate_email_format(form_data.email.lower()):
         raise HTTPException(