|
|
|
|
@ -9,10 +9,11 @@ import MailAndPasswordAuth from './components/mail-and-password-auth'
|
|
|
|
|
import SocialAuth from './components/social-auth'
|
|
|
|
|
import SSOAuth from './components/sso-auth'
|
|
|
|
|
import cn from '@/utils/classnames'
|
|
|
|
|
import { getSystemFeatures, invitationCheck } from '@/service/common'
|
|
|
|
|
import { LicenseStatus, defaultSystemFeatures } from '@/types/feature'
|
|
|
|
|
import { invitationCheck } from '@/service/common'
|
|
|
|
|
import { LicenseStatus } from '@/types/feature'
|
|
|
|
|
import Toast from '@/app/components/base/toast'
|
|
|
|
|
import { IS_CE_EDITION } from '@/config'
|
|
|
|
|
import { useGlobalPublicStore } from '@/context/global-public-context'
|
|
|
|
|
|
|
|
|
|
const NormalForm = () => {
|
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
@ -23,7 +24,7 @@ const NormalForm = () => {
|
|
|
|
|
const message = decodeURIComponent(searchParams.get('message') || '')
|
|
|
|
|
const invite_token = decodeURIComponent(searchParams.get('invite_token') || '')
|
|
|
|
|
const [isLoading, setIsLoading] = useState(true)
|
|
|
|
|
const [systemFeatures, setSystemFeatures] = useState(defaultSystemFeatures)
|
|
|
|
|
const { systemFeatures } = useGlobalPublicStore()
|
|
|
|
|
const [authType, updateAuthType] = useState<'code' | 'password'>('password')
|
|
|
|
|
const [showORLine, setShowORLine] = useState(false)
|
|
|
|
|
const [allMethodsAreDisabled, setAllMethodsAreDisabled] = useState(false)
|
|
|
|
|
@ -46,12 +47,9 @@ const NormalForm = () => {
|
|
|
|
|
message,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const features = await getSystemFeatures()
|
|
|
|
|
const allFeatures = { ...defaultSystemFeatures, ...features }
|
|
|
|
|
setSystemFeatures(allFeatures)
|
|
|
|
|
setAllMethodsAreDisabled(!allFeatures.enable_social_oauth_login && !allFeatures.enable_email_code_login && !allFeatures.enable_email_password_login && !allFeatures.sso_enforced_for_signin)
|
|
|
|
|
setShowORLine((allFeatures.enable_social_oauth_login || allFeatures.sso_enforced_for_signin) && (allFeatures.enable_email_code_login || allFeatures.enable_email_password_login))
|
|
|
|
|
updateAuthType(allFeatures.enable_email_password_login ? 'password' : 'code')
|
|
|
|
|
setAllMethodsAreDisabled(!systemFeatures.enable_social_oauth_login && !systemFeatures.enable_email_code_login && !systemFeatures.enable_email_password_login && !systemFeatures.sso_enforced_for_signin)
|
|
|
|
|
setShowORLine((systemFeatures.enable_social_oauth_login || systemFeatures.sso_enforced_for_signin) && (systemFeatures.enable_email_code_login || systemFeatures.enable_email_password_login))
|
|
|
|
|
updateAuthType(systemFeatures.enable_email_password_login ? 'password' : 'code')
|
|
|
|
|
if (isInviteLink) {
|
|
|
|
|
const checkRes = await invitationCheck({
|
|
|
|
|
url: '/activate/check',
|
|
|
|
|
@ -65,10 +63,9 @@ const NormalForm = () => {
|
|
|
|
|
catch (error) {
|
|
|
|
|
console.error(error)
|
|
|
|
|
setAllMethodsAreDisabled(true)
|
|
|
|
|
setSystemFeatures(defaultSystemFeatures)
|
|
|
|
|
}
|
|
|
|
|
finally { setIsLoading(false) }
|
|
|
|
|
}, [consoleToken, refreshToken, message, router, invite_token, isInviteLink])
|
|
|
|
|
}, [consoleToken, refreshToken, message, router, invite_token, isInviteLink, systemFeatures])
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
init()
|
|
|
|
|
}, [init])
|
|
|
|
|
@ -83,7 +80,7 @@ const NormalForm = () => {
|
|
|
|
|
<Loading type='area' />
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
if (systemFeatures.license?.status === LicenseStatus.LOST) {
|
|
|
|
|
if (systemFeatures.license.status === LicenseStatus.LOST) {
|
|
|
|
|
return <div className='w-full mx-auto mt-8'>
|
|
|
|
|
<div className='bg-white'>
|
|
|
|
|
<div className="p-4 rounded-lg bg-gradient-to-r from-workflow-workflow-progress-bg-1 to-workflow-workflow-progress-bg-2">
|
|
|
|
|
@ -97,7 +94,7 @@ const NormalForm = () => {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
if (systemFeatures.license?.status === LicenseStatus.EXPIRED) {
|
|
|
|
|
if (systemFeatures.license.status === LicenseStatus.EXPIRED) {
|
|
|
|
|
return <div className='w-full mx-auto mt-8'>
|
|
|
|
|
<div className='bg-white'>
|
|
|
|
|
<div className="p-4 rounded-lg bg-gradient-to-r from-workflow-workflow-progress-bg-1 to-workflow-workflow-progress-bg-2">
|
|
|
|
|
@ -111,7 +108,7 @@ const NormalForm = () => {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
if (systemFeatures.license?.status === LicenseStatus.INACTIVE) {
|
|
|
|
|
if (systemFeatures.license.status === LicenseStatus.INACTIVE) {
|
|
|
|
|
return <div className='w-full mx-auto mt-8'>
|
|
|
|
|
<div className='bg-white'>
|
|
|
|
|
<div className="p-4 rounded-lg bg-gradient-to-r from-workflow-workflow-progress-bg-1 to-workflow-workflow-progress-bg-2">
|
|
|
|
|
@ -132,11 +129,11 @@ const NormalForm = () => {
|
|
|
|
|
{isInviteLink
|
|
|
|
|
? <div className="w-full mx-auto">
|
|
|
|
|
<h2 className="title-4xl-semi-bold text-text-primary">{t('login.join')}{workspaceName}</h2>
|
|
|
|
|
<p className='mt-2 body-md-regular text-text-tertiary'>{t('login.joinTipStart')}{workspaceName}{t('login.joinTipEnd')}</p>
|
|
|
|
|
{!systemFeatures.branding.enabled && <p className='mt-2 body-md-regular text-text-tertiary'>{t('login.joinTipStart')}{workspaceName}{t('login.joinTipEnd')}</p>}
|
|
|
|
|
</div>
|
|
|
|
|
: <div className="w-full mx-auto">
|
|
|
|
|
<h2 className="title-4xl-semi-bold text-text-primary">{t('login.pageTitle')}</h2>
|
|
|
|
|
<p className='mt-2 body-md-regular text-text-tertiary'>{t('login.welcome')}</p>
|
|
|
|
|
{!systemFeatures.branding.enabled && <p className='mt-2 body-md-regular text-text-tertiary'>{t('login.welcome')}</p>}
|
|
|
|
|
</div>}
|
|
|
|
|
<div className="bg-white">
|
|
|
|
|
<div className="flex flex-col gap-3 mt-6">
|
|
|
|
|
@ -184,29 +181,31 @@ const NormalForm = () => {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>}
|
|
|
|
|
<div className="w-full block mt-2 system-xs-regular text-text-tertiary">
|
|
|
|
|
{t('login.tosDesc')}
|
|
|
|
|
|
|
|
|
|
<Link
|
|
|
|
|
className='system-xs-medium text-text-secondary hover:underline'
|
|
|
|
|
target='_blank' rel='noopener noreferrer'
|
|
|
|
|
href='https://dify.ai/terms'
|
|
|
|
|
>{t('login.tos')}</Link>
|
|
|
|
|
&
|
|
|
|
|
<Link
|
|
|
|
|
className='system-xs-medium text-text-secondary hover:underline'
|
|
|
|
|
target='_blank' rel='noopener noreferrer'
|
|
|
|
|
href='https://dify.ai/privacy'
|
|
|
|
|
>{t('login.pp')}</Link>
|
|
|
|
|
</div>
|
|
|
|
|
{IS_CE_EDITION && <div className="w-hull block mt-2 system-xs-regular text-text-tertiary">
|
|
|
|
|
{t('login.goToInit')}
|
|
|
|
|
|
|
|
|
|
<Link
|
|
|
|
|
className='system-xs-medium text-text-secondary hover:underline'
|
|
|
|
|
href='/install'
|
|
|
|
|
>{t('login.setAdminAccount')}</Link>
|
|
|
|
|
</div>}
|
|
|
|
|
{!systemFeatures.branding.enabled && <>
|
|
|
|
|
<div className="w-full block mt-2 system-xs-regular text-text-tertiary">
|
|
|
|
|
{t('login.tosDesc')}
|
|
|
|
|
|
|
|
|
|
<Link
|
|
|
|
|
className='system-xs-medium text-text-secondary hover:underline'
|
|
|
|
|
target='_blank' rel='noopener noreferrer'
|
|
|
|
|
href='https://dify.ai/terms'
|
|
|
|
|
>{t('login.tos')}</Link>
|
|
|
|
|
&
|
|
|
|
|
<Link
|
|
|
|
|
className='system-xs-medium text-text-secondary hover:underline'
|
|
|
|
|
target='_blank' rel='noopener noreferrer'
|
|
|
|
|
href='https://dify.ai/privacy'
|
|
|
|
|
>{t('login.pp')}</Link>
|
|
|
|
|
</div>
|
|
|
|
|
{IS_CE_EDITION && <div className="w-hull block mt-2 system-xs-regular text-text-tertiary">
|
|
|
|
|
{t('login.goToInit')}
|
|
|
|
|
|
|
|
|
|
<Link
|
|
|
|
|
className='system-xs-medium text-text-secondary hover:underline'
|
|
|
|
|
href='/install'
|
|
|
|
|
>{t('login.setAdminAccount')}</Link>
|
|
|
|
|
</div>}
|
|
|
|
|
</>}
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|