Skip to content

Commit f7415e1

Browse files
authored
feat: Disable the "Forgot your password?" button when the mail server setup is incomplete (#11653)
1 parent 2961fa0 commit f7415e1

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

api/services/feature_service.py

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class SystemFeatureModel(BaseModel):
6363
enable_social_oauth_login: bool = False
6464
is_allow_register: bool = False
6565
is_allow_create_workspace: bool = False
66+
is_email_setup: bool = False
6667
license: LicenseModel = LicenseModel()
6768

6869

@@ -98,6 +99,7 @@ def _fulfill_system_params_from_env(cls, system_features: SystemFeatureModel):
9899
system_features.enable_social_oauth_login = dify_config.ENABLE_SOCIAL_OAUTH_LOGIN
99100
system_features.is_allow_register = dify_config.ALLOW_REGISTER
100101
system_features.is_allow_create_workspace = dify_config.ALLOW_CREATE_WORKSPACE
102+
system_features.is_email_setup = dify_config.MAIL_TYPE is not None and dify_config.MAIL_TYPE != ""
101103

102104
@classmethod
103105
def _fulfill_params_from_env(cls, features: FeatureModel):

web/app/signin/components/mail-and-password-auth.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import I18NContext from '@/context/i18n'
1212

1313
type MailAndPasswordAuthProps = {
1414
isInvite: boolean
15+
isEmailSetup: boolean
1516
allowRegistration: boolean
1617
}
1718

1819
const passwordRegex = /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/
1920

20-
export default function MailAndPasswordAuth({ isInvite, allowRegistration }: MailAndPasswordAuthProps) {
21+
export default function MailAndPasswordAuth({ isInvite, isEmailSetup, allowRegistration }: MailAndPasswordAuthProps) {
2122
const { t } = useTranslation()
2223
const { locale } = useContext(I18NContext)
2324
const router = useRouter()
@@ -124,7 +125,12 @@ export default function MailAndPasswordAuth({ isInvite, allowRegistration }: Mai
124125
<div className='mb-3'>
125126
<label htmlFor="password" className="my-2 flex items-center justify-between">
126127
<span className='system-md-semibold text-text-secondary'>{t('login.password')}</span>
127-
<Link href={`/reset-password?${searchParams.toString()}`} className='system-xs-regular text-components-button-secondary-accent-text'>
128+
<Link
129+
href={`/reset-password?${searchParams.toString()}`}
130+
className={`system-xs-regular ${isEmailSetup ? 'text-components-button-secondary-accent-text' : 'text-components-button-secondary-accent-text-disabled pointer-events-none'}`}
131+
tabIndex={isEmailSetup ? 0 : -1}
132+
aria-disabled={!isEmailSetup}
133+
>
128134
{t('login.forget')}
129135
</Link>
130136
</label>

web/app/signin/normalForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const NormalForm = () => {
163163
</div>}
164164
</>}
165165
{systemFeatures.enable_email_password_login && authType === 'password' && <>
166-
<MailAndPasswordAuth isInvite={isInviteLink} allowRegistration={systemFeatures.is_allow_register} />
166+
<MailAndPasswordAuth isInvite={isInviteLink} isEmailSetup={systemFeatures.is_email_setup} allowRegistration={systemFeatures.is_allow_register} />
167167
{systemFeatures.enable_email_code_login && <div className='cursor-pointer py-1 text-center' onClick={() => { updateAuthType('code') }}>
168168
<span className='system-xs-medium text-components-button-secondary-accent-text'>{t('login.useVerificationCode')}</span>
169169
</div>}

web/types/feature.ts

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export type SystemFeatures = {
2929
enable_social_oauth_login: boolean
3030
is_allow_create_workspace: boolean
3131
is_allow_register: boolean
32+
is_email_setup: boolean
3233
license: License
3334
}
3435

@@ -43,6 +44,7 @@ export const defaultSystemFeatures: SystemFeatures = {
4344
enable_social_oauth_login: false,
4445
is_allow_create_workspace: false,
4546
is_allow_register: false,
47+
is_email_setup: false,
4648
license: {
4749
status: LicenseStatus.NONE,
4850
expired_at: '',

0 commit comments

Comments
 (0)