瀏覽代碼

refac: automatically disable new sign ups after first user

Timothy J. Baek 6 月之前
父節點
當前提交
98cea8aaa4
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      backend/open_webui/apps/webui/routers/auths.py

+ 5 - 0
backend/open_webui/apps/webui/routers/auths.py

@@ -260,6 +260,11 @@ async def signup(request: Request, response: Response, form_data: SignupForm):
             if Users.get_num_users() == 0
             else request.app.state.config.DEFAULT_USER_ROLE
         )
+
+        if Users.get_num_users() == 0:
+            # Disable signup after the first user is created
+            request.app.state.config.ENABLE_SIGNUP = False
+
         hashed = get_password_hash(form_data.password)
         user = Auths.insert_new_auth(
             form_data.email.lower(),