mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac/enh
This commit is contained in:
parent
2bb6063dcb
commit
12bd04d24d
3 changed files with 17 additions and 7 deletions
|
|
@ -404,6 +404,10 @@ except ValueError:
|
||||||
####################################
|
####################################
|
||||||
|
|
||||||
WEBUI_AUTH = os.environ.get("WEBUI_AUTH", "True").lower() == "true"
|
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 = (
|
ENABLE_SIGNUP_PASSWORD_CONFIRMATION = (
|
||||||
os.environ.get("ENABLE_SIGNUP_PASSWORD_CONFIRMATION", "False").lower() == "true"
|
os.environ.get("ENABLE_SIGNUP_PASSWORD_CONFIRMATION", "False").lower() == "true"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ from open_webui.env import (
|
||||||
WEBUI_AUTH_COOKIE_SAME_SITE,
|
WEBUI_AUTH_COOKIE_SAME_SITE,
|
||||||
WEBUI_AUTH_COOKIE_SECURE,
|
WEBUI_AUTH_COOKIE_SECURE,
|
||||||
WEBUI_AUTH_SIGNOUT_REDIRECT_URL,
|
WEBUI_AUTH_SIGNOUT_REDIRECT_URL,
|
||||||
|
ENABLE_INITIAL_ADMIN_SIGNUP,
|
||||||
SRC_LOG_LEVELS,
|
SRC_LOG_LEVELS,
|
||||||
)
|
)
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||||
|
|
@ -569,9 +570,10 @@ async def signup(request: Request, response: Response, form_data: SignupForm):
|
||||||
not request.app.state.config.ENABLE_SIGNUP
|
not request.app.state.config.ENABLE_SIGNUP
|
||||||
or not request.app.state.config.ENABLE_LOGIN_FORM
|
or not request.app.state.config.ENABLE_LOGIN_FORM
|
||||||
):
|
):
|
||||||
raise HTTPException(
|
if has_users or not ENABLE_INITIAL_ADMIN_SIGNUP:
|
||||||
status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.ACCESS_PROHIBITED
|
raise HTTPException(
|
||||||
)
|
status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.ACCESS_PROHIBITED
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if has_users:
|
if has_users:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
let mode = $config?.features.enable_ldap ? 'ldap' : 'signin';
|
let mode = $config?.features.enable_ldap ? 'ldap' : 'signin';
|
||||||
|
|
||||||
|
let form = null;
|
||||||
|
|
||||||
let name = '';
|
let name = '';
|
||||||
let email = '';
|
let email = '';
|
||||||
let password = '';
|
let password = '';
|
||||||
|
|
@ -147,11 +149,13 @@
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if ($user !== undefined) {
|
if ($user !== undefined) {
|
||||||
const redirectPath = querystringValue('redirect') || '/';
|
const redirectPath = $page.url.searchParams.get('redirect') || '/';
|
||||||
goto(redirectPath);
|
goto(redirectPath);
|
||||||
}
|
}
|
||||||
await checkOauthCallback();
|
await checkOauthCallback();
|
||||||
|
|
||||||
|
form = $page.url.searchParams.get('form');
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
setLogoImage();
|
setLogoImage();
|
||||||
|
|
||||||
|
|
@ -246,7 +250,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</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">
|
<div class="flex flex-col mt-4">
|
||||||
{#if mode === 'signup'}
|
{#if mode === 'signup'}
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
|
|
@ -337,7 +341,7 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="mt-5">
|
<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'}
|
{#if mode === 'ldap'}
|
||||||
<button
|
<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"
|
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}
|
{#if Object.keys($config?.oauth?.providers ?? {}).length > 0}
|
||||||
<div class="inline-flex items-center justify-center w-full">
|
<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" />
|
<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
|
<span
|
||||||
class="px-3 text-sm font-medium text-gray-900 dark:text-white bg-transparent"
|
class="px-3 text-sm font-medium text-gray-900 dark:text-white bg-transparent"
|
||||||
>{$i18n.t('or')}</span
|
>{$i18n.t('or')}</span
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue