refac/enh

This commit is contained in:
Timothy Jaeryang Baek 2025-08-28 03:24:26 +04:00
parent 2bb6063dcb
commit 12bd04d24d
3 changed files with 17 additions and 7 deletions

View file

@ -404,6 +404,10 @@ except ValueError:
####################################
WEBUI_AUTH = os.environ.get("WEBUI_AUTH", "True").lower() == "true"
ENABLE_INITIAL_ADMIN_SIGNUP = (
os.environ.get("ENABLE_INITIAL_ADMIN_SIGNUP", "False").lower() == "true"
)
ENABLE_SIGNUP_PASSWORD_CONFIRMATION = (
os.environ.get("ENABLE_SIGNUP_PASSWORD_CONFIRMATION", "False").lower() == "true"
)

View file

@ -29,6 +29,7 @@ from open_webui.env import (
WEBUI_AUTH_COOKIE_SAME_SITE,
WEBUI_AUTH_COOKIE_SECURE,
WEBUI_AUTH_SIGNOUT_REDIRECT_URL,
ENABLE_INITIAL_ADMIN_SIGNUP,
SRC_LOG_LEVELS,
)
from fastapi import APIRouter, Depends, HTTPException, Request, status
@ -569,6 +570,7 @@ async def signup(request: Request, response: Response, form_data: SignupForm):
not request.app.state.config.ENABLE_SIGNUP
or not request.app.state.config.ENABLE_LOGIN_FORM
):
if has_users or not ENABLE_INITIAL_ADMIN_SIGNUP:
raise HTTPException(
status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.ACCESS_PROHIBITED
)

View file

@ -26,6 +26,8 @@
let mode = $config?.features.enable_ldap ? 'ldap' : 'signin';
let form = null;
let name = '';
let email = '';
let password = '';
@ -147,11 +149,13 @@
onMount(async () => {
if ($user !== undefined) {
const redirectPath = querystringValue('redirect') || '/';
const redirectPath = $page.url.searchParams.get('redirect') || '/';
goto(redirectPath);
}
await checkOauthCallback();
form = $page.url.searchParams.get('form');
loaded = true;
setLogoImage();
@ -246,7 +250,7 @@
{/if}
</div>
{#if $config?.features.enable_login_form || $config?.features.enable_ldap}
{#if $config?.features.enable_login_form || $config?.features.enable_ldap || form}
<div class="flex flex-col mt-4">
{#if mode === 'signup'}
<div class="mb-2">
@ -337,7 +341,7 @@
</div>
{/if}
<div class="mt-5">
{#if $config?.features.enable_login_form || $config?.features.enable_ldap}
{#if $config?.features.enable_login_form || $config?.features.enable_ldap || form}
{#if mode === 'ldap'}
<button
class="bg-gray-700/5 hover:bg-gray-700/10 dark:bg-gray-100/5 dark:hover:bg-gray-100/10 dark:text-gray-300 dark:hover:text-white transition w-full rounded-full font-medium text-sm py-2.5"
@ -386,7 +390,7 @@
{#if Object.keys($config?.oauth?.providers ?? {}).length > 0}
<div class="inline-flex items-center justify-center w-full">
<hr class="w-32 h-px my-4 border-0 dark:bg-gray-100/10 bg-gray-700/10" />
{#if $config?.features.enable_login_form || $config?.features.enable_ldap}
{#if $config?.features.enable_login_form || $config?.features.enable_ldap || form}
<span
class="px-3 text-sm font-medium text-gray-900 dark:text-white bg-transparent"
>{$i18n.t('or')}</span