feat: Disable the "Forgot your password?" button when the mail server setup is incomplete (#11653)
This commit is contained in:
parent
2961fa0e08
commit
f7415e1ca4
@ -63,6 +63,7 @@ class SystemFeatureModel(BaseModel):
|
|||||||
enable_social_oauth_login: bool = False
|
enable_social_oauth_login: bool = False
|
||||||
is_allow_register: bool = False
|
is_allow_register: bool = False
|
||||||
is_allow_create_workspace: bool = False
|
is_allow_create_workspace: bool = False
|
||||||
|
is_email_setup: bool = False
|
||||||
license: LicenseModel = LicenseModel()
|
license: LicenseModel = LicenseModel()
|
||||||
|
|
||||||
|
|
||||||
@ -98,6 +99,7 @@ class FeatureService:
|
|||||||
system_features.enable_social_oauth_login = dify_config.ENABLE_SOCIAL_OAUTH_LOGIN
|
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_register = dify_config.ALLOW_REGISTER
|
||||||
system_features.is_allow_create_workspace = dify_config.ALLOW_CREATE_WORKSPACE
|
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
|
@classmethod
|
||||||
def _fulfill_params_from_env(cls, features: FeatureModel):
|
def _fulfill_params_from_env(cls, features: FeatureModel):
|
||||||
|
@ -12,12 +12,13 @@ import I18NContext from '@/context/i18n'
|
|||||||
|
|
||||||
type MailAndPasswordAuthProps = {
|
type MailAndPasswordAuthProps = {
|
||||||
isInvite: boolean
|
isInvite: boolean
|
||||||
|
isEmailSetup: boolean
|
||||||
allowRegistration: boolean
|
allowRegistration: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const passwordRegex = /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/
|
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 { t } = useTranslation()
|
||||||
const { locale } = useContext(I18NContext)
|
const { locale } = useContext(I18NContext)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -124,7 +125,12 @@ export default function MailAndPasswordAuth({ isInvite, allowRegistration }: Mai
|
|||||||
<div className='mb-3'>
|
<div className='mb-3'>
|
||||||
<label htmlFor="password" className="my-2 flex items-center justify-between">
|
<label htmlFor="password" className="my-2 flex items-center justify-between">
|
||||||
<span className='system-md-semibold text-text-secondary'>{t('login.password')}</span>
|
<span className='system-md-semibold text-text-secondary'>{t('login.password')}</span>
|
||||||
<Link href={`/reset-password?${searchParams.toString()}`} className='system-xs-regular text-components-button-secondary-accent-text'>
|
<Link
|
||||||
|
href={`/reset-password?${searchParams.toString()}`}
|
||||||
|
className={`system-xs-regular ${isEmailSetup ? 'text-components-button-secondary-accent-text' : 'text-components-button-secondary-accent-text-disabled pointer-events-none'}`}
|
||||||
|
tabIndex={isEmailSetup ? 0 : -1}
|
||||||
|
aria-disabled={!isEmailSetup}
|
||||||
|
>
|
||||||
{t('login.forget')}
|
{t('login.forget')}
|
||||||
</Link>
|
</Link>
|
||||||
</label>
|
</label>
|
||||||
|
@ -163,7 +163,7 @@ const NormalForm = () => {
|
|||||||
</div>}
|
</div>}
|
||||||
</>}
|
</>}
|
||||||
{systemFeatures.enable_email_password_login && authType === 'password' && <>
|
{systemFeatures.enable_email_password_login && authType === 'password' && <>
|
||||||
<MailAndPasswordAuth isInvite={isInviteLink} allowRegistration={systemFeatures.is_allow_register} />
|
<MailAndPasswordAuth isInvite={isInviteLink} isEmailSetup={systemFeatures.is_email_setup} allowRegistration={systemFeatures.is_allow_register} />
|
||||||
{systemFeatures.enable_email_code_login && <div className='cursor-pointer py-1 text-center' onClick={() => { updateAuthType('code') }}>
|
{systemFeatures.enable_email_code_login && <div className='cursor-pointer py-1 text-center' onClick={() => { updateAuthType('code') }}>
|
||||||
<span className='system-xs-medium text-components-button-secondary-accent-text'>{t('login.useVerificationCode')}</span>
|
<span className='system-xs-medium text-components-button-secondary-accent-text'>{t('login.useVerificationCode')}</span>
|
||||||
</div>}
|
</div>}
|
||||||
|
@ -29,6 +29,7 @@ export type SystemFeatures = {
|
|||||||
enable_social_oauth_login: boolean
|
enable_social_oauth_login: boolean
|
||||||
is_allow_create_workspace: boolean
|
is_allow_create_workspace: boolean
|
||||||
is_allow_register: boolean
|
is_allow_register: boolean
|
||||||
|
is_email_setup: boolean
|
||||||
license: License
|
license: License
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +44,7 @@ export const defaultSystemFeatures: SystemFeatures = {
|
|||||||
enable_social_oauth_login: false,
|
enable_social_oauth_login: false,
|
||||||
is_allow_create_workspace: false,
|
is_allow_create_workspace: false,
|
||||||
is_allow_register: false,
|
is_allow_register: false,
|
||||||
|
is_email_setup: false,
|
||||||
license: {
|
license: {
|
||||||
status: LicenseStatus.NONE,
|
status: LicenseStatus.NONE,
|
||||||
expired_at: '',
|
expired_at: '',
|
||||||
|
Loading…
Reference in New Issue
Block a user