From f7415e1ca47b6c4903925f5beab6077a77567df5 Mon Sep 17 00:00:00 2001 From: Shun Miyazawa <34241526+miya@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:20:41 +0900 Subject: [PATCH] feat: Disable the "Forgot your password?" button when the mail server setup is incomplete (#11653) --- api/services/feature_service.py | 2 ++ web/app/signin/components/mail-and-password-auth.tsx | 10 ++++++++-- web/app/signin/normalForm.tsx | 2 +- web/types/feature.ts | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/api/services/feature_service.py b/api/services/feature_service.py index 6bd82a2757..0386c6acea 100644 --- a/api/services/feature_service.py +++ b/api/services/feature_service.py @@ -63,6 +63,7 @@ class SystemFeatureModel(BaseModel): enable_social_oauth_login: bool = False is_allow_register: bool = False is_allow_create_workspace: bool = False + is_email_setup: bool = False license: LicenseModel = LicenseModel() @@ -98,6 +99,7 @@ class FeatureService: system_features.enable_social_oauth_login = dify_config.ENABLE_SOCIAL_OAUTH_LOGIN system_features.is_allow_register = dify_config.ALLOW_REGISTER system_features.is_allow_create_workspace = dify_config.ALLOW_CREATE_WORKSPACE + system_features.is_email_setup = dify_config.MAIL_TYPE is not None and dify_config.MAIL_TYPE != "" @classmethod def _fulfill_params_from_env(cls, features: FeatureModel): diff --git a/web/app/signin/components/mail-and-password-auth.tsx b/web/app/signin/components/mail-and-password-auth.tsx index 210c877bb7..97f8bd1bec 100644 --- a/web/app/signin/components/mail-and-password-auth.tsx +++ b/web/app/signin/components/mail-and-password-auth.tsx @@ -12,12 +12,13 @@ import I18NContext from '@/context/i18n' type MailAndPasswordAuthProps = { isInvite: boolean + isEmailSetup: boolean allowRegistration: boolean } const passwordRegex = /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/ -export default function MailAndPasswordAuth({ isInvite, allowRegistration }: MailAndPasswordAuthProps) { +export default function MailAndPasswordAuth({ isInvite, isEmailSetup, allowRegistration }: MailAndPasswordAuthProps) { const { t } = useTranslation() const { locale } = useContext(I18NContext) const router = useRouter() @@ -124,7 +125,12 @@ export default function MailAndPasswordAuth({ isInvite, allowRegistration }: Mai