From 709b56bc409abdc0b725aa6b5f183259a3c43923 Mon Sep 17 00:00:00 2001 From: Dillon Date: Tue, 23 Jul 2024 22:19:41 -0400 Subject: [PATCH 1/6] imported and added new ENABLE_USERNAME_PASSWORD_LOGIN environment variable --- backend/apps/webui/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/apps/webui/main.py b/backend/apps/webui/main.py index 570cad9f1..f74acd916 100644 --- a/backend/apps/webui/main.py +++ b/backend/apps/webui/main.py @@ -35,6 +35,7 @@ from config import ( DEFAULT_PROMPT_SUGGESTIONS, DEFAULT_USER_ROLE, ENABLE_SIGNUP, + ENABLE_USERNAME_PASSWORD_LOGIN, USER_PERMISSIONS, WEBHOOK_URL, WEBUI_AUTH_TRUSTED_EMAIL_HEADER, @@ -64,6 +65,7 @@ origins = ["*"] app.state.config = AppConfig() app.state.config.ENABLE_SIGNUP = ENABLE_SIGNUP +app.state.config.ENABLE_USERNAME_PASSWORD_LOGIN = ENABLE_USERNAME_PASSWORD_LOGIN app.state.config.JWT_EXPIRES_IN = JWT_EXPIRES_IN app.state.AUTH_TRUSTED_EMAIL_HEADER = WEBUI_AUTH_TRUSTED_EMAIL_HEADER app.state.AUTH_TRUSTED_NAME_HEADER = WEBUI_AUTH_TRUSTED_NAME_HEADER From f9289d3079aaa1dbda379033fb9645a0536b5db4 Mon Sep 17 00:00:00 2001 From: Dillon Date: Tue, 23 Jul 2024 22:20:45 -0400 Subject: [PATCH 2/6] Created new PersistentConfig for new environment variable ENABLE_USERNAME_PASSWORD_LOGIN --- backend/config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/config.py b/backend/config.py index fe68eee34..166f82042 100644 --- a/backend/config.py +++ b/backend/config.py @@ -709,6 +709,12 @@ ENABLE_SIGNUP = PersistentConfig( ), ) +ENABLE_USERNAME_PASSWORD_LOGIN = PersistentConfig( + "ENABLE_USERNAME_PASSWORD_LOGIN", + "ui.enable_username_password_login", + os.environ.get("ENABLE_USERNAME_PASSWORD_LOGIN", "True").lower() == "true", +) + DEFAULT_LOCALE = PersistentConfig( "DEFAULT_LOCALE", "ui.default_locale", From 63ffdb38aa3a969553c0fdb97e16bd1bdadd8275 Mon Sep 17 00:00:00 2001 From: Dillon Date: Tue, 23 Jul 2024 22:22:09 -0400 Subject: [PATCH 3/6] Added and set enable_username_password_login to the get_app_config function --- backend/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/main.py b/backend/main.py index 62f07a868..218221e59 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1995,6 +1995,7 @@ async def get_app_config(): "auth": WEBUI_AUTH, "auth_trusted_header": bool(webui_app.state.AUTH_TRUSTED_EMAIL_HEADER), "enable_signup": webui_app.state.config.ENABLE_SIGNUP, + "enable_username_password_login": webui_app.state.config.ENABLE_USERNAME_PASSWORD_LOGIN, "enable_web_search": rag_app.state.config.ENABLE_RAG_WEB_SEARCH, "enable_image_generation": images_app.state.config.ENABLED, "enable_community_sharing": webui_app.state.config.ENABLE_COMMUNITY_SHARING, From b56dcf155c93e13878fbeb1ad61d90cbf575aab2 Mon Sep 17 00:00:00 2001 From: Dillon Date: Tue, 23 Jul 2024 22:23:37 -0400 Subject: [PATCH 4/6] Added enable_username_password_login to the Config object --- src/lib/stores/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.ts index bf8fb20c7..8a68f91fb 100644 --- a/src/lib/stores/index.ts +++ b/src/lib/stores/index.ts @@ -145,6 +145,7 @@ type Config = { auth: boolean; auth_trusted_header: boolean; enable_signup: boolean; + enable_username_password_login: boolean; enable_web_search?: boolean; enable_image_generation: boolean; enable_admin_export: boolean; From 4ecf9dd62d8e53bfca08bc38a46019b2c9f2b995 Mon Sep 17 00:00:00 2001 From: Dillon Date: Tue, 23 Jul 2024 22:25:29 -0400 Subject: [PATCH 5/6] Created if blocks to show or hide username, password, signin and or sections depending on new enable_username_password_login variable --- src/routes/auth/+page.svelte | 144 ++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 69 deletions(-) diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte index 830ac3a5b..2da0367e1 100644 --- a/src/routes/auth/+page.svelte +++ b/src/routes/auth/+page.svelte @@ -173,88 +173,94 @@ {/if} -
- {#if mode === 'signup'} -
-
{$i18n.t('Name')}
+ {#if $config?.features.enable_username_password_login} +
+ {#if mode === 'signup'} +
+
{$i18n.t('Name')}
+ +
+ +
+ {/if} + +
+
{$i18n.t('Email')}
-
- {/if} +
+
{$i18n.t('Password')}
-
-
{$i18n.t('Email')}
- -
- -
-
{$i18n.t('Password')}
- - -
-
- -
- - - {#if $config?.features.enable_signup} -
- {mode === 'signin' - ? $i18n.t("Don't have an account?") - : $i18n.t('Already have an account?')} - - +
- {/if} -
+
+ {/if} + + {#if $config?.features.enable_username_password_login} +
+ + + {#if $config?.features.enable_signup} +
+ {mode === 'signin' + ? $i18n.t("Don't have an account?") + : $i18n.t('Already have an account?')} + + +
+ {/if} +
+ {/if} {#if Object.keys($config?.oauth?.providers ?? {}).length > 0}

- {$i18n.t('or')} + {#if $config?.features.enable_username_password_login} + {$i18n.t('or')} + {/if}
{#if $config?.oauth?.providers?.google} From 36b94ca5f5c32f647612e252313ed184215450a9 Mon Sep 17 00:00:00 2001 From: Dillon Date: Wed, 24 Jul 2024 21:44:40 -0400 Subject: [PATCH 6/6] updated environment variable to suggested ENABLE_LOGIN_FORM --- backend/apps/webui/main.py | 4 ++-- backend/config.py | 8 ++++---- backend/main.py | 2 +- src/lib/stores/index.ts | 2 +- src/routes/auth/+page.svelte | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/backend/apps/webui/main.py b/backend/apps/webui/main.py index f74acd916..46b9a4ac5 100644 --- a/backend/apps/webui/main.py +++ b/backend/apps/webui/main.py @@ -35,7 +35,7 @@ from config import ( DEFAULT_PROMPT_SUGGESTIONS, DEFAULT_USER_ROLE, ENABLE_SIGNUP, - ENABLE_USERNAME_PASSWORD_LOGIN, + ENABLE_LOGIN_FORM, USER_PERMISSIONS, WEBHOOK_URL, WEBUI_AUTH_TRUSTED_EMAIL_HEADER, @@ -65,7 +65,7 @@ origins = ["*"] app.state.config = AppConfig() app.state.config.ENABLE_SIGNUP = ENABLE_SIGNUP -app.state.config.ENABLE_USERNAME_PASSWORD_LOGIN = ENABLE_USERNAME_PASSWORD_LOGIN +app.state.config.ENABLE_LOGIN_FORM = ENABLE_LOGIN_FORM app.state.config.JWT_EXPIRES_IN = JWT_EXPIRES_IN app.state.AUTH_TRUSTED_EMAIL_HEADER = WEBUI_AUTH_TRUSTED_EMAIL_HEADER app.state.AUTH_TRUSTED_NAME_HEADER = WEBUI_AUTH_TRUSTED_NAME_HEADER diff --git a/backend/config.py b/backend/config.py index 166f82042..9715ca403 100644 --- a/backend/config.py +++ b/backend/config.py @@ -709,10 +709,10 @@ ENABLE_SIGNUP = PersistentConfig( ), ) -ENABLE_USERNAME_PASSWORD_LOGIN = PersistentConfig( - "ENABLE_USERNAME_PASSWORD_LOGIN", - "ui.enable_username_password_login", - os.environ.get("ENABLE_USERNAME_PASSWORD_LOGIN", "True").lower() == "true", +ENABLE_LOGIN_FORM = PersistentConfig( + "ENABLE_LOGIN_FORM", + "ui.ENABLE_LOGIN_FORM", + os.environ.get("ENABLE_LOGIN_FORM", "True").lower() == "true", ) DEFAULT_LOCALE = PersistentConfig( diff --git a/backend/main.py b/backend/main.py index 218221e59..16d7b2b40 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1995,7 +1995,7 @@ async def get_app_config(): "auth": WEBUI_AUTH, "auth_trusted_header": bool(webui_app.state.AUTH_TRUSTED_EMAIL_HEADER), "enable_signup": webui_app.state.config.ENABLE_SIGNUP, - "enable_username_password_login": webui_app.state.config.ENABLE_USERNAME_PASSWORD_LOGIN, + "enable_login_form": webui_app.state.config.ENABLE_LOGIN_FORM, "enable_web_search": rag_app.state.config.ENABLE_RAG_WEB_SEARCH, "enable_image_generation": images_app.state.config.ENABLED, "enable_community_sharing": webui_app.state.config.ENABLE_COMMUNITY_SHARING, diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.ts index 8a68f91fb..1b0257c4b 100644 --- a/src/lib/stores/index.ts +++ b/src/lib/stores/index.ts @@ -145,7 +145,7 @@ type Config = { auth: boolean; auth_trusted_header: boolean; enable_signup: boolean; - enable_username_password_login: boolean; + enable_login_form: boolean; enable_web_search?: boolean; enable_image_generation: boolean; enable_admin_export: boolean; diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte index 2da0367e1..b0f13e386 100644 --- a/src/routes/auth/+page.svelte +++ b/src/routes/auth/+page.svelte @@ -173,7 +173,7 @@ {/if}
- {#if $config?.features.enable_username_password_login} + {#if $config?.features.enable_login_form}
{#if mode === 'signup'}
@@ -218,7 +218,7 @@
{/if} - {#if $config?.features.enable_username_password_login} + {#if $config?.features.enable_login_form}