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