Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): give auth pages one shared shell (#45599)

yyhded73505c347
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index ddf4aac9eb3..1c264bb964a 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -292,12 +292,8 @@
/web/app/components/plugins/marketplace/ @iamjoel @Yessenia-d
# Frontend - Login and Registration
-/web/app/signin/ @iamjoel
-/web/app/signup/ @iamjoel
-/web/app/reset-password/ @iamjoel
-/web/app/install/ @iamjoel
-/web/app/init/ @iamjoel
-/web/app/forgot-password/ @iamjoel
+/web/app/(auth)/ @iamjoel
+/web/app/components/auth-shell/ @iamjoel
/web/app/account/ @iamjoel
# Frontend - Service Authentication
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index 44c2ccb6638..48220077525 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -42,6 +42,29 @@
"count": 1
}
},
+ "web/app/(auth)/device/components/code-input.tsx": {
+ "jsx-a11y/no-autofocus": {
+ "count": 1
+ }
+ },
+ "web/app/(auth)/device/page.tsx": {
+ "dify/require-disable-directive-description": {
+ "count": 5
+ },
+ "jsx-a11y/no-autofocus": {
+ "count": 1
+ }
+ },
+ "web/app/(auth)/init/InitPasswordPopup.tsx": {
+ "typescript/no-explicit-any": {
+ "count": 1
+ }
+ },
+ "web/app/(auth)/signin/normal-form.tsx": {
+ "@tanstack/query/prefer-query-options": {
+ "count": 1
+ }
+ },
"web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx": {
"better-tailwindcss/enforce-logical-properties": {
"count": 1
@@ -83,9 +106,6 @@
}
},
"web/app/(shareLayout)/webapp-signin/normalForm.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 3
- },
"jsx-a11y/click-events-have-key-events": {
"count": 2
},
@@ -6106,24 +6126,6 @@
"count": 3
}
},
- "web/app/device/_header.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 1
- }
- },
- "web/app/device/components/code-input.tsx": {
- "jsx-a11y/no-autofocus": {
- "count": 1
- }
- },
- "web/app/device/page.tsx": {
- "dify/require-disable-directive-description": {
- "count": 5
- },
- "jsx-a11y/no-autofocus": {
- "count": 1
- }
- },
"web/app/education/apply/applied-education-content.tsx": {
"better-tailwindcss/enforce-logical-properties": {
"count": 2
@@ -6134,49 +6136,6 @@
"count": 5
}
},
- "web/app/init/InitPasswordPopup.tsx": {
- "typescript/no-explicit-any": {
- "count": 1
- }
- },
- "web/app/reset-password/check-code/page.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 1
- }
- },
- "web/app/reset-password/page.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 1
- }
- },
- "web/app/signin/_header.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 1
- }
- },
- "web/app/signin/_locale-menu.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 3
- }
- },
- "web/app/signin/check-code/page.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 1
- }
- },
- "web/app/signin/normal-form.tsx": {
- "@tanstack/query/prefer-query-options": {
- "count": 1
- },
- "better-tailwindcss/enforce-logical-properties": {
- "count": 3
- }
- },
- "web/app/signup/check-code/page.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 1
- }
- },
"web/context/hooks/use-trigger-events-limit-modal.ts": {
"eslint-react/set-state-in-effect": {
"count": 1
diff --git a/web/app/account/oauth/authorize/__tests__/page.spec.tsx b/web/app/(auth)/account/oauth/authorize/__tests__/page.spec.tsx
similarity index 100%
rename from web/app/account/oauth/authorize/__tests__/page.spec.tsx
rename to web/app/(auth)/account/oauth/authorize/__tests__/page.spec.tsx
diff --git a/web/app/account/oauth/authorize/__tests__/use-silent-authorize.spec.ts b/web/app/(auth)/account/oauth/authorize/__tests__/use-silent-authorize.spec.ts
similarity index 100%
rename from web/app/account/oauth/authorize/__tests__/use-silent-authorize.spec.ts
rename to web/app/(auth)/account/oauth/authorize/__tests__/use-silent-authorize.spec.ts
diff --git a/web/app/(auth)/account/oauth/authorize/layout.tsx b/web/app/(auth)/account/oauth/authorize/layout.tsx
new file mode 100644
index 00000000000..d61245fd81a
--- /dev/null
+++ b/web/app/(auth)/account/oauth/authorize/layout.tsx
@@ -0,0 +1,11 @@
+import type { ReactNode } from 'react'
+import { OAuthRegistrationAnalytics } from '@/app/components/oauth-registration-analytics'
+
+export default function OAuthAuthorizeLayout({ children }: { children: ReactNode }) {
+ return (
+ <>
+ <OAuthRegistrationAnalytics />
+ {children}
+ </>
+ )
+}
diff --git a/web/app/account/oauth/authorize/page.tsx b/web/app/(auth)/account/oauth/authorize/page.tsx
similarity index 100%
rename from web/app/account/oauth/authorize/page.tsx
rename to web/app/(auth)/account/oauth/authorize/page.tsx
diff --git a/web/app/account/oauth/authorize/use-silent-authorize.ts b/web/app/(auth)/account/oauth/authorize/use-silent-authorize.ts
similarity index 100%
rename from web/app/account/oauth/authorize/use-silent-authorize.ts
rename to web/app/(auth)/account/oauth/authorize/use-silent-authorize.ts
diff --git a/web/app/activate/activateForm.tsx b/web/app/(auth)/activate/activateForm.tsx
similarity index 93%
rename from web/app/activate/activateForm.tsx
rename to web/app/(auth)/activate/activateForm.tsx
index c725cf2dd61..7191e4327d7 100644
--- a/web/app/activate/activateForm.tsx
+++ b/web/app/(auth)/activate/activateForm.tsx
@@ -48,12 +48,10 @@ const ActivateForm = () => {
}, [checkRes, router, searchParams, token])
return (
- <div
- className={cn('flex w-full grow flex-col items-center justify-center', 'px-6', 'md:px-27')}
- >
+ <>
{!checkRes && <LoadingPlaceholder />}
{checkRes && !checkRes.is_valid && (
- <div className="flex flex-col md:w-100">
+ <div className="flex flex-col">
<div className="mx-auto w-full">
<div className="mb-3 flex h-20 w-20 items-center justify-center rounded-[20px] border border-divider-regular bg-components-option-card-option-bg p-5 text-[40px] font-bold shadow-lg">
🤷‍♂️
@@ -72,7 +70,7 @@ const ActivateForm = () => {
</div>
</div>
)}
- </div>
+ </>
)
}
diff --git a/web/app/(auth)/activate/page.tsx b/web/app/(auth)/activate/page.tsx
new file mode 100644
index 00000000000..ebc831c8d6e
--- /dev/null
+++ b/web/app/(auth)/activate/page.tsx
@@ -0,0 +1,7 @@
+import ActivateForm from './activateForm'
+
+const Activate = () => {
+ return <ActivateForm />
+}
+
+export default Activate
diff --git a/web/app/device/__tests__/page-terminal.spec.tsx b/web/app/(auth)/device/__tests__/page-terminal.spec.tsx
similarity index 100%
rename from web/app/device/__tests__/page-terminal.spec.tsx
rename to web/app/(auth)/device/__tests__/page-terminal.spec.tsx
diff --git a/web/app/device/components/__tests__/authorize-account.spec.tsx b/web/app/(auth)/device/components/__tests__/authorize-account.spec.tsx
similarity index 100%
rename from web/app/device/components/__tests__/authorize-account.spec.tsx
rename to web/app/(auth)/device/components/__tests__/authorize-account.spec.tsx
diff --git a/web/app/device/components/__tests__/authorize-sso.spec.tsx b/web/app/(auth)/device/components/__tests__/authorize-sso.spec.tsx
similarity index 100%
rename from web/app/device/components/__tests__/authorize-sso.spec.tsx
rename to web/app/(auth)/device/components/__tests__/authorize-sso.spec.tsx
diff --git a/web/app/device/components/__tests__/chooser.spec.tsx b/web/app/(auth)/device/components/__tests__/chooser.spec.tsx
similarity index 84%
rename from web/app/device/components/__tests__/chooser.spec.tsx
rename to web/app/(auth)/device/components/__tests__/chooser.spec.tsx
index 02ff4357d3a..3f6a87d25a3 100644
--- a/web/app/device/components/__tests__/chooser.spec.tsx
+++ b/web/app/(auth)/device/components/__tests__/chooser.spec.tsx
@@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
-import { setPostLoginRedirect } from '@/app/signin/utils/post-login-redirect'
+import { setPostLoginRedirect } from '@/app/(auth)/signin/utils/post-login-redirect'
import Chooser from '../chooser'
-vi.mock('@/app/signin/utils/post-login-redirect', () => ({ setPostLoginRedirect: vi.fn() }))
+vi.mock('@/app/(auth)/signin/utils/post-login-redirect', () => ({ setPostLoginRedirect: vi.fn() }))
it('keeps the device code when starting account sign-in without SSO', async () => {
const user = userEvent.setup()
diff --git a/web/app/device/components/authorize-account.tsx b/web/app/(auth)/device/components/authorize-account.tsx
similarity index 100%
rename from web/app/device/components/authorize-account.tsx
rename to web/app/(auth)/device/components/authorize-account.tsx
diff --git a/web/app/device/components/authorize-sso.tsx b/web/app/(auth)/device/components/authorize-sso.tsx
similarity index 100%
rename from web/app/device/components/authorize-sso.tsx
rename to web/app/(auth)/device/components/authorize-sso.tsx
diff --git a/web/app/device/components/chooser.tsx b/web/app/(auth)/device/components/chooser.tsx
similarity index 95%
rename from web/app/device/components/chooser.tsx
rename to web/app/(auth)/device/components/chooser.tsx
index 5c1f76fe5d2..cc192f74d84 100644
--- a/web/app/device/components/chooser.tsx
+++ b/web/app/(auth)/device/components/chooser.tsx
@@ -4,7 +4,7 @@ import type { FC } from 'react'
import { buttonVariants } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import { useTranslation } from 'react-i18next'
-import { setPostLoginRedirect } from '@/app/signin/utils/post-login-redirect'
+import { setPostLoginRedirect } from '@/app/(auth)/signin/utils/post-login-redirect'
import Link from '@/next/link'
type Props = {
diff --git a/web/app/device/components/code-input.tsx b/web/app/(auth)/device/components/code-input.tsx
similarity index 100%
rename from web/app/device/components/code-input.tsx
rename to web/app/(auth)/device/components/code-input.tsx
diff --git a/web/app/device/page.tsx b/web/app/(auth)/device/page.tsx
similarity index 100%
rename from web/app/device/page.tsx
rename to web/app/(auth)/device/page.tsx
diff --git a/web/app/device/utils/error-copy.ts b/web/app/(auth)/device/utils/error-copy.ts
similarity index 100%
rename from web/app/device/utils/error-copy.ts
rename to web/app/(auth)/device/utils/error-copy.ts
diff --git a/web/app/device/utils/user-code.ts b/web/app/(auth)/device/utils/user-code.ts
similarity index 100%
rename from web/app/device/utils/user-code.ts
rename to web/app/(auth)/device/utils/user-code.ts
diff --git a/web/app/forgot-password/ChangePasswordForm.spec.tsx b/web/app/(auth)/forgot-password/ChangePasswordForm.spec.tsx
similarity index 100%
rename from web/app/forgot-password/ChangePasswordForm.spec.tsx
rename to web/app/(auth)/forgot-password/ChangePasswordForm.spec.tsx
diff --git a/web/app/forgot-password/ChangePasswordForm.tsx b/web/app/(auth)/forgot-password/ChangePasswordForm.tsx
similarity index 97%
rename from web/app/forgot-password/ChangePasswordForm.tsx
rename to web/app/(auth)/forgot-password/ChangePasswordForm.tsx
index 3ae86bd56f2..4a11d70aabe 100644
--- a/web/app/forgot-password/ChangePasswordForm.tsx
+++ b/web/app/(auth)/forgot-password/ChangePasswordForm.tsx
@@ -78,12 +78,10 @@ const ChangePasswordForm = () => {
)
return (
- <div
- className={cn('flex w-full grow flex-col items-center justify-center', 'px-6', 'md:px-27')}
- >
+ <>
{isVerifyingToken && <LoadingPlaceholder />}
{isTokenInvalid && (
- <div className="flex flex-col md:w-100">
+ <div className="flex flex-col">
<div className="mx-auto w-full">
<div className="mb-3 flex h-20 w-20 items-center justify-center rounded-[20px] border border-divider-regular bg-components-option-card-option-bg p-5 text-[40px] font-bold shadow-lg">
🤷‍♂️
@@ -103,7 +101,7 @@ const ChangePasswordForm = () => {
</div>
)}
{verifyTokenRes && verifyTokenRes.is_valid && !showSuccess && (
- <div className="flex flex-col md:w-100">
+ <div className="flex flex-col">
<div className="mx-auto w-full">
<h1 className="text-[32px] font-bold text-text-primary">
{t(($) => $.changePassword, { ns: 'login' })}
@@ -210,7 +208,7 @@ const ChangePasswordForm = () => {
</div>
)}
{verifyTokenRes && verifyTokenRes.is_valid && showSuccess && (
- <div className="flex flex-col md:w-100">
+ <div className="flex flex-col">
<div className="mx-auto w-full">
<div className="mb-3 flex h-20 w-20 items-center justify-center rounded-[20px] border border-divider-regular bg-components-option-card-option-bg p-5 text-[40px] font-bold shadow-lg">
<span
@@ -232,7 +230,7 @@ const ChangePasswordForm = () => {
</div>
</div>
)}
- </div>
+ </>
)
}
diff --git a/web/app/forgot-password/ForgotPasswordForm.spec.tsx b/web/app/(auth)/forgot-password/ForgotPasswordForm.spec.tsx
similarity index 100%
rename from web/app/forgot-password/ForgotPasswordForm.spec.tsx
rename to web/app/(auth)/forgot-password/ForgotPasswordForm.spec.tsx
diff --git a/web/app/forgot-password/ForgotPasswordForm.tsx b/web/app/(auth)/forgot-password/ForgotPasswordForm.tsx
similarity index 95%
rename from web/app/forgot-password/ForgotPasswordForm.tsx
rename to web/app/(auth)/forgot-password/ForgotPasswordForm.tsx
index 332e0999127..29da9d615d3 100644
--- a/web/app/forgot-password/ForgotPasswordForm.tsx
+++ b/web/app/(auth)/forgot-password/ForgotPasswordForm.tsx
@@ -59,10 +59,10 @@ const ForgotPasswordForm = () => {
}, [])
return loading ? (
- <LoadingPlaceholder className="grow" />
+ <LoadingPlaceholder />
) : (
<>
- <div className="sm:mx-auto sm:w-full sm:max-w-md">
+ <div>
<h1 className="text-[32px] font-bold text-text-primary">
{isEmailSent
? t(($) => $.resetLinkSent, { ns: 'login' })
@@ -74,7 +74,7 @@ const ForgotPasswordForm = () => {
: t(($) => $.forgotPasswordDesc, { ns: 'login' })}
</p>
</div>
- <div className="mt-8 grow sm:mx-auto sm:w-full sm:max-w-md">
+ <div className="mt-8">
<div className="relative">
<Form<ForgotPasswordFormValues>
onFormSubmit={(value) => {
diff --git a/web/app/(auth)/forgot-password/page.tsx b/web/app/(auth)/forgot-password/page.tsx
new file mode 100644
index 00000000000..9c6722fd451
--- /dev/null
+++ b/web/app/(auth)/forgot-password/page.tsx
@@ -0,0 +1,13 @@
+'use client'
+import ChangePasswordForm from '@/app/(auth)/forgot-password/ChangePasswordForm'
+import { useSearchParams } from '@/next/navigation'
+import ForgotPasswordForm from './ForgotPasswordForm'
+
+const ForgotPassword = () => {
+ const searchParams = useSearchParams()
+ const token = searchParams.get('token')
+
+ return token ? <ChangePasswordForm /> : <ForgotPasswordForm />
+}
+
+export default ForgotPassword
diff --git a/web/app/init/InitPasswordPopup.tsx b/web/app/(auth)/init/InitPasswordPopup.tsx
similarity index 100%
rename from web/app/init/InitPasswordPopup.tsx
rename to web/app/(auth)/init/InitPasswordPopup.tsx
diff --git a/web/app/(auth)/init/page.tsx b/web/app/(auth)/init/page.tsx
new file mode 100644
index 00000000000..4e1f499071c
--- /dev/null
+++ b/web/app/(auth)/init/page.tsx
@@ -0,0 +1,12 @@
+import { getRouteMetadata } from '@/app/route-metadata'
+import InitPasswordPopup from './InitPasswordPopup'
+
+export function generateMetadata() {
+ return getRouteMetadata('login', ($) => $.adminInitPassword)
+}
+
+const Init = () => {
+ return <InitPasswordPopup />
+}
+
+export default Init
diff --git a/web/app/install/installForm.spec.tsx b/web/app/(auth)/install/installForm.spec.tsx
similarity index 100%
rename from web/app/install/installForm.spec.tsx
rename to web/app/(auth)/install/installForm.spec.tsx
diff --git a/web/app/install/installForm.tsx b/web/app/(auth)/install/installForm.tsx
similarity index 97%
rename from web/app/install/installForm.tsx
rename to web/app/(auth)/install/installForm.tsx
index 638196a4b23..3b49f6ccde3 100644
--- a/web/app/install/installForm.tsx
+++ b/web/app/(auth)/install/installForm.tsx
@@ -129,16 +129,16 @@ const InstallForm = () => {
initStatus.data.status !== 'not_started'
return !canSetup ? (
- <LoadingPlaceholder className="grow" />
+ <LoadingPlaceholder />
) : (
<>
- <div className="sm:mx-auto sm:w-full sm:max-w-md">
+ <div>
<h1 className="text-[32px] font-bold text-text-primary">{pageTitle}</h1>
<p className="mt-1 text-sm text-text-secondary">
{t(($) => $.setAdminAccountDesc, { ns: 'login' })}
</p>
</div>
- <div className="mt-8 grow sm:mx-auto sm:w-full sm:max-w-md">
+ <div className="mt-8">
<div className="relative">
<Form<AccountFormValues> onFormSubmit={(value) => void handleSubmit(value)}>
<Field
diff --git a/web/app/install/layout.tsx b/web/app/(auth)/install/layout.tsx
similarity index 100%
rename from web/app/install/layout.tsx
rename to web/app/(auth)/install/layout.tsx
diff --git a/web/app/(auth)/install/page.tsx b/web/app/(auth)/install/page.tsx
new file mode 100644
index 00000000000..0ba0678fac1
--- /dev/null
+++ b/web/app/(auth)/install/page.tsx
@@ -0,0 +1,7 @@
+import InstallForm from './installForm'
+
+const Install = () => {
+ return <InstallForm />
+}
+
+export default Install
diff --git a/web/app/(auth)/layout.tsx b/web/app/(auth)/layout.tsx
new file mode 100644
index 00000000000..fe0345808f8
--- /dev/null
+++ b/web/app/(auth)/layout.tsx
@@ -0,0 +1,6 @@
+import type { ReactNode } from 'react'
+import { AuthShell } from '@/app/components/auth-shell'
+
+export default function AuthLayout({ children }: { children: ReactNode }) {
+ return <AuthShell>{children}</AuthShell>
+}
diff --git a/web/app/reset-password/__tests__/page.spec.tsx b/web/app/(auth)/reset-password/__tests__/page.spec.tsx
similarity index 100%
rename from web/app/reset-password/__tests__/page.spec.tsx
rename to web/app/(auth)/reset-password/__tests__/page.spec.tsx
diff --git a/web/app/reset-password/check-code/__tests__/page.spec.tsx b/web/app/(auth)/reset-password/check-code/__tests__/page.spec.tsx
similarity index 100%
rename from web/app/reset-password/check-code/__tests__/page.spec.tsx
rename to web/app/(auth)/reset-password/check-code/__tests__/page.spec.tsx
diff --git a/web/app/reset-password/check-code/layout.tsx b/web/app/(auth)/reset-password/check-code/layout.tsx
similarity index 100%
rename from web/app/reset-password/check-code/layout.tsx
rename to web/app/(auth)/reset-password/check-code/layout.tsx
diff --git a/web/app/reset-password/check-code/page.tsx b/web/app/(auth)/reset-password/check-code/page.tsx
similarity index 98%
rename from web/app/reset-password/check-code/page.tsx
rename to web/app/(auth)/reset-password/check-code/page.tsx
index cee7db31da3..4599ad61b2d 100644
--- a/web/app/reset-password/check-code/page.tsx
+++ b/web/app/(auth)/reset-password/check-code/page.tsx
@@ -115,7 +115,7 @@ export default function CheckCode() {
<span className="inline-block rounded-full bg-background-default-dimmed p-1">
<span className="i-ri-arrow-left-line size-3" aria-hidden="true" />
</span>
- <span className="ml-2 system-xs-regular">{t(($) => $.back, { ns: 'login' })}</span>
+ <span className="ms-2 system-xs-regular">{t(($) => $.back, { ns: 'login' })}</span>
</button>
</div>
)
diff --git a/web/app/reset-password/layout.tsx b/web/app/(auth)/reset-password/layout.tsx
similarity index 66%
rename from web/app/reset-password/layout.tsx
rename to web/app/(auth)/reset-password/layout.tsx
index c0f876f1eef..6dfcf9eca61 100644
--- a/web/app/reset-password/layout.tsx
+++ b/web/app/(auth)/reset-password/layout.tsx
@@ -1,10 +1,9 @@
import { getRouteMetadata } from '@/app/route-metadata'
-import ResetPasswordLayout from './reset-password-layout'
export function generateMetadata() {
return getRouteMetadata('login', ($) => $.resetPassword)
}
export default function SignInLayout({ children }: { children: React.ReactNode }) {
- return <ResetPasswordLayout>{children}</ResetPasswordLayout>
+ return children
}
diff --git a/web/app/reset-password/page.tsx b/web/app/(auth)/reset-password/page.tsx
similarity index 96%
rename from web/app/reset-password/page.tsx
rename to web/app/(auth)/reset-password/page.tsx
index 62bb3f9c882..5a51f29daf7 100644
--- a/web/app/reset-password/page.tsx
+++ b/web/app/(auth)/reset-password/page.tsx
@@ -6,13 +6,13 @@ import { Input } from '@langgenius/dify-ui/input'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useLocale } from '#i18n'
+import { COUNT_DOWN_TIME_MS, useSetCountdownLeftTime } from '@/app/components/signin/storage'
import { toast } from '@/app/notifications'
import { emailRegex } from '@/config'
import useDocumentTitle from '@/hooks/use-document-title'
import Link from '@/next/link'
import { useRouter, useSearchParams } from '@/next/navigation'
import { consoleClient } from '@/service/console'
-import { COUNT_DOWN_TIME_MS, useSetCountdownLeftTime } from '../components/signin/storage'
export default function CheckCode() {
const { t } = useTranslation(['login'])
@@ -107,7 +107,7 @@ export default function CheckCode() {
<div className="inline-block rounded-full bg-background-default-dimmed p-1">
<span className="i-ri-arrow-left-line size-3" aria-hidden="true" />
</div>
- <span className="ml-2 system-xs-regular">{t(($) => $.backToLogin, { ns: 'login' })}</span>
+ <span className="ms-2 system-xs-regular">{t(($) => $.backToLogin, { ns: 'login' })}</span>
</Link>
</div>
)
diff --git a/web/app/reset-password/set-password/__tests__/page.spec.tsx b/web/app/(auth)/reset-password/set-password/__tests__/page.spec.tsx
similarity index 100%
rename from web/app/reset-password/set-password/__tests__/page.spec.tsx
rename to web/app/(auth)/reset-password/set-password/__tests__/page.spec.tsx
diff --git a/web/app/reset-password/set-password/layout.tsx b/web/app/(auth)/reset-password/set-password/layout.tsx
similarity index 100%
rename from web/app/reset-password/set-password/layout.tsx
rename to web/app/(auth)/reset-password/set-password/layout.tsx
diff --git a/web/app/reset-password/set-password/page.tsx b/web/app/(auth)/reset-password/set-password/page.tsx
similarity index 97%
rename from web/app/reset-password/set-password/page.tsx
rename to web/app/(auth)/reset-password/set-password/page.tsx
index 7b51daecb1f..288577908fd 100644
--- a/web/app/reset-password/set-password/page.tsx
+++ b/web/app/(auth)/reset-password/set-password/page.tsx
@@ -95,11 +95,9 @@ const ChangePasswordForm = () => {
)
return (
- <div
- className={cn('flex w-full grow flex-col items-center justify-center', 'px-6', 'md:px-27')}
- >
+ <>
{!showSuccess && (
- <div className="flex flex-col md:w-100">
+ <div className="flex flex-col">
<div className="mx-auto w-full">
<h1 className="title-4xl-semi-bold text-text-primary">
{t(($) => $.changePassword, { ns: 'login' })}
@@ -198,7 +196,7 @@ const ChangePasswordForm = () => {
</div>
)}
{showSuccess && (
- <div className="flex flex-col md:w-100">
+ <div className="flex flex-col">
<div className="mx-auto w-full">
<div className="mb-3 flex size-14 items-center justify-center rounded-2xl border border-components-panel-border-subtle font-bold shadow-lg">
<span
@@ -221,7 +219,7 @@ const ChangePasswordForm = () => {
</div>
</div>
)}
- </div>
+ </>
)
}
diff --git a/web/app/signin/__tests__/normal-form.spec.tsx b/web/app/(auth)/signin/__tests__/normal-form.spec.tsx
similarity index 100%
rename from web/app/signin/__tests__/normal-form.spec.tsx
rename to web/app/(auth)/signin/__tests__/normal-form.spec.tsx
diff --git a/web/app/signin/__tests__/one-more-step.spec.tsx b/web/app/(auth)/signin/__tests__/one-more-step.spec.tsx
similarity index 100%
rename from web/app/signin/__tests__/one-more-step.spec.tsx
rename to web/app/(auth)/signin/__tests__/one-more-step.spec.tsx
diff --git a/web/app/signin/__tests__/page.spec.tsx b/web/app/(auth)/signin/__tests__/page.spec.tsx
similarity index 100%
rename from web/app/signin/__tests__/page.spec.tsx
rename to web/app/(auth)/signin/__tests__/page.spec.tsx
diff --git a/web/app/signin/assets/github-dark.svg b/web/app/(auth)/signin/assets/github-dark.svg
similarity index 100%
rename from web/app/signin/assets/github-dark.svg
rename to web/app/(auth)/signin/assets/github-dark.svg
diff --git a/web/app/signin/assets/github.svg b/web/app/(auth)/signin/assets/github.svg
similarity index 100%
rename from web/app/signin/assets/github.svg
rename to web/app/(auth)/signin/assets/github.svg
diff --git a/web/app/signin/assets/google.svg b/web/app/(auth)/signin/assets/google.svg
similarity index 100%
rename from web/app/signin/assets/google.svg
rename to web/app/(auth)/signin/assets/google.svg
diff --git a/web/app/signin/check-code/__tests__/page.spec.tsx b/web/app/(auth)/signin/check-code/__tests__/page.spec.tsx
similarity index 100%
rename from web/app/signin/check-code/__tests__/page.spec.tsx
rename to web/app/(auth)/signin/check-code/__tests__/page.spec.tsx
diff --git a/web/app/signin/check-code/layout.tsx b/web/app/(auth)/signin/check-code/layout.tsx
similarity index 100%
rename from web/app/signin/check-code/layout.tsx
rename to web/app/(auth)/signin/check-code/layout.tsx
diff --git a/web/app/signin/check-code/page.tsx b/web/app/(auth)/signin/check-code/page.tsx
similarity index 99%
rename from web/app/signin/check-code/page.tsx
rename to web/app/(auth)/signin/check-code/page.tsx
index e78a6338542..2dd8369ebbf 100644
--- a/web/app/signin/check-code/page.tsx
+++ b/web/app/(auth)/signin/check-code/page.tsx
@@ -238,7 +238,7 @@ export default function CheckCode() {
<span className="inline-block rounded-full bg-background-default-dimmed p-1">
<span className="i-ri-arrow-left-line size-3" aria-hidden="true" />
</span>
- <span className="ml-2 system-xs-regular">{t(($) => $.back, { ns: 'login' })}</span>
+ <span className="ms-2 system-xs-regular">{t(($) => $.back, { ns: 'login' })}</span>
</button>
</div>
)
diff --git a/web/app/signin/components/__tests__/mail-and-code-auth.spec.tsx b/web/app/(auth)/signin/components/__tests__/mail-and-code-auth.spec.tsx
similarity index 100%
rename from web/app/signin/components/__tests__/mail-and-code-auth.spec.tsx
rename to web/app/(auth)/signin/components/__tests__/mail-and-code-auth.spec.tsx
diff --git a/web/app/signin/components/__tests__/social-auth.spec.tsx b/web/app/(auth)/signin/components/__tests__/social-auth.spec.tsx
similarity index 100%
rename from web/app/signin/components/__tests__/social-auth.spec.tsx
rename to web/app/(auth)/signin/components/__tests__/social-auth.spec.tsx
diff --git a/web/app/signin/components/__tests__/sso-auth.spec.tsx b/web/app/(auth)/signin/components/__tests__/sso-auth.spec.tsx
similarity index 100%
rename from web/app/signin/components/__tests__/sso-auth.spec.tsx
rename to web/app/(auth)/signin/components/__tests__/sso-auth.spec.tsx
diff --git a/web/app/signin/components/__tests__/turnstile.spec.tsx b/web/app/(auth)/signin/components/__tests__/turnstile.spec.tsx
similarity index 100%
rename from web/app/signin/components/__tests__/turnstile.spec.tsx
rename to web/app/(auth)/signin/components/__tests__/turnstile.spec.tsx
diff --git a/web/app/signin/components/mail-and-code-auth.tsx b/web/app/(auth)/signin/components/mail-and-code-auth.tsx
similarity index 100%
rename from web/app/signin/components/mail-and-code-auth.tsx
rename to web/app/(auth)/signin/components/mail-and-code-auth.tsx
diff --git a/web/app/signin/components/mail-and-password-auth.tsx b/web/app/(auth)/signin/components/mail-and-password-auth.tsx
similarity index 100%
rename from web/app/signin/components/mail-and-password-auth.tsx
rename to web/app/(auth)/signin/components/mail-and-password-auth.tsx
diff --git a/web/app/signin/components/social-auth.tsx b/web/app/(auth)/signin/components/social-auth.tsx
similarity index 100%
rename from web/app/signin/components/social-auth.tsx
rename to web/app/(auth)/signin/components/social-auth.tsx
diff --git a/web/app/signin/components/sso-auth.tsx b/web/app/(auth)/signin/components/sso-auth.tsx
similarity index 100%
rename from web/app/signin/components/sso-auth.tsx
rename to web/app/(auth)/signin/components/sso-auth.tsx
diff --git a/web/app/signin/components/turnstile.tsx b/web/app/(auth)/signin/components/turnstile.tsx
similarity index 100%
rename from web/app/signin/components/turnstile.tsx
rename to web/app/(auth)/signin/components/turnstile.tsx
diff --git a/web/app/signin/invite-settings/__tests__/page.spec.tsx b/web/app/(auth)/signin/invite-settings/__tests__/page.spec.tsx
similarity index 100%
rename from web/app/signin/invite-settings/__tests__/page.spec.tsx
rename to web/app/(auth)/signin/invite-settings/__tests__/page.spec.tsx
diff --git a/web/app/signin/invite-settings/page.tsx b/web/app/(auth)/signin/invite-settings/page.tsx
similarity index 99%
rename from web/app/signin/invite-settings/page.tsx
rename to web/app/(auth)/signin/invite-settings/page.tsx
index 9cf8176757b..6df72bf3d01 100644
--- a/web/app/signin/invite-settings/page.tsx
+++ b/web/app/(auth)/signin/invite-settings/page.tsx
@@ -188,7 +188,7 @@ export default function InviteSettingsPage() {
if (isProfilePending || shouldReturnToSignIn || !checkRes) return <LoadingPlaceholder />
if (!checkRes.is_valid) {
return (
- <div className="flex flex-col md:w-100">
+ <div className="flex flex-col">
<div className="mx-auto w-full">
<div className="mb-3 flex size-14 items-center justify-center rounded-2xl border border-components-panel-border-subtle text-2xl font-bold shadow-lg">
🤷‍♂️
diff --git a/web/app/signin/normal-form.tsx b/web/app/(auth)/signin/normal-form.tsx
similarity index 96%
rename from web/app/signin/normal-form.tsx
rename to web/app/(auth)/signin/normal-form.tsx
index bf2ec7e84cd..5dd0482fca5 100644
--- a/web/app/signin/normal-form.tsx
+++ b/web/app/(auth)/signin/normal-form.tsx
@@ -1,5 +1,4 @@
import { zLicenseStatus } from '@dify/contracts/api/console/system-features/zod.gen'
-import { cn } from '@langgenius/dify-ui/cn'
import { RiContractLine, RiDoorLockLine, RiErrorWarningFill } from '@remixicon/react'
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
import { useEffect, useState } from 'react'
@@ -107,13 +106,7 @@ function NormalForm() {
}, [message])
if (isLoading) {
- return (
- <div
- className={cn('flex w-full grow flex-col items-center justify-center', 'px-6', 'md:px-27')}
- >
- <LoadingPlaceholder />
- </div>
- )
+ return <LoadingPlaceholder />
}
if (systemFeatures.license?.status === zLicenseStatus.enum.lost) {
return (
@@ -122,7 +115,7 @@ function NormalForm() {
<div className="rounded-lg bg-linear-to-r from-workflow-workflow-progress-bg-1 to-workflow-workflow-progress-bg-2 p-4">
<div className="relative mb-2 flex size-10 items-center justify-center rounded-xl bg-components-card-bg shadow">
<RiContractLine className="size-5" />
- <RiErrorWarningFill className="absolute -top-1 -right-1 size-4 text-text-warning-secondary" />
+ <RiErrorWarningFill className="absolute -inset-e-1 -top-1 size-4 text-text-warning-secondary" />
</div>
<p className="system-sm-medium text-text-primary">
{t(($) => $.licenseLost, { ns: 'login' })}
@@ -142,7 +135,7 @@ function NormalForm() {
<div className="rounded-lg bg-linear-to-r from-workflow-workflow-progress-bg-1 to-workflow-workflow-progress-bg-2 p-4">
<div className="relative mb-2 flex size-10 items-center justify-center rounded-xl bg-components-card-bg shadow">
<RiContractLine className="size-5" />
- <RiErrorWarningFill className="absolute -top-1 -right-1 size-4 text-text-warning-secondary" />
+ <RiErrorWarningFill className="absolute -inset-e-1 -top-1 size-4 text-text-warning-secondary" />
</div>
<p className="system-sm-medium text-text-primary">
{t(($) => $.licenseExpired, { ns: 'login' })}
@@ -162,7 +155,7 @@ function NormalForm() {
<div className="rounded-lg bg-linear-to-r from-workflow-workflow-progress-bg-1 to-workflow-workflow-progress-bg-2 p-4">
<div className="relative mb-2 flex size-10 items-center justify-center rounded-xl bg-components-card-bg shadow">
<RiContractLine className="size-5" />
- <RiErrorWarningFill className="absolute -top-1 -right-1 size-4 text-text-warning-secondary" />
+ <RiErrorWarningFill className="absolute -inset-e-1 -top-1 size-4 text-text-warning-secondary" />
</div>
<p className="system-sm-medium text-text-primary">
{t(($) => $.licenseInactive, { ns: 'login' })}
diff --git a/web/app/signin/one-more-step.tsx b/web/app/(auth)/signin/one-more-step.tsx
similarity index 98%
rename from web/app/signin/one-more-step.tsx
rename to web/app/(auth)/signin/one-more-step.tsx
index 6e046ef9b8f..1587f062ff8 100644
--- a/web/app/signin/one-more-step.tsx
+++ b/web/app/(auth)/signin/one-more-step.tsx
@@ -18,8 +18,8 @@ import {
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { useReducer } from 'react'
import { useTranslation } from 'react-i18next'
+import { resolvePostLoginRedirect } from '@/app/(auth)/signin/utils/post-login-redirect'
import { toast } from '@/app/notifications'
-import { resolvePostLoginRedirect } from '@/app/signin/utils/post-login-redirect'
import { LICENSE_LINK } from '@/constants/link'
import { languages } from '@/i18n/language'
import Link from '@/next/link'
diff --git a/web/app/signin/page.module.css b/web/app/(auth)/signin/page.module.css
similarity index 100%
rename from web/app/signin/page.module.css
rename to web/app/(auth)/signin/page.module.css
diff --git a/web/app/signin/page.tsx b/web/app/(auth)/signin/page.tsx
similarity index 100%
rename from web/app/signin/page.tsx
rename to web/app/(auth)/signin/page.tsx
diff --git a/web/app/signin/sign-in-page.tsx b/web/app/(auth)/signin/sign-in-page.tsx
similarity index 100%
rename from web/app/signin/sign-in-page.tsx
rename to web/app/(auth)/signin/sign-in-page.tsx
diff --git a/web/app/signin/split.tsx b/web/app/(auth)/signin/split.tsx
similarity index 100%
rename from web/app/signin/split.tsx
rename to web/app/(auth)/signin/split.tsx
diff --git a/web/app/signin/utils/__tests__/post-login-redirect.spec.ts b/web/app/(auth)/signin/utils/__tests__/post-login-redirect.spec.ts
similarity index 100%
rename from web/app/signin/utils/__tests__/post-login-redirect.spec.ts
rename to web/app/(auth)/signin/utils/__tests__/post-login-redirect.spec.ts
diff --git a/web/app/signin/utils/invitation-account.ts b/web/app/(auth)/signin/utils/invitation-account.ts
similarity index 100%
rename from web/app/signin/utils/invitation-account.ts
rename to web/app/(auth)/signin/utils/invitation-account.ts
diff --git a/web/app/signin/utils/post-login-redirect.ts b/web/app/(auth)/signin/utils/post-login-redirect.ts
similarity index 100%
rename from web/app/signin/utils/post-login-redirect.ts
rename to web/app/(auth)/signin/utils/post-login-redirect.ts
diff --git a/web/app/signup/check-code/__tests__/page.spec.tsx b/web/app/(auth)/signup/check-code/__tests__/page.spec.tsx
similarity index 100%
rename from web/app/signup/check-code/__tests__/page.spec.tsx
rename to web/app/(auth)/signup/check-code/__tests__/page.spec.tsx
diff --git a/web/app/signup/check-code/layout.tsx b/web/app/(auth)/signup/check-code/layout.tsx
similarity index 100%
rename from web/app/signup/check-code/layout.tsx
rename to web/app/(auth)/signup/check-code/layout.tsx
diff --git a/web/app/signup/check-code/page.tsx b/web/app/(auth)/signup/check-code/page.tsx
similarity index 98%
rename from web/app/signup/check-code/page.tsx
rename to web/app/(auth)/signup/check-code/page.tsx
index 4439016e04b..c2c5d19621b 100644
--- a/web/app/signup/check-code/page.tsx
+++ b/web/app/(auth)/signup/check-code/page.tsx
@@ -129,7 +129,7 @@ export default function CheckCode() {
<span className="inline-block rounded-full p-1">
<span className="i-ri-arrow-left-line size-3" aria-hidden="true" />
</span>
- <span className="ml-2 system-xs-regular">{t(($) => $.back, { ns: 'login' })}</span>
+ <span className="ms-2 system-xs-regular">{t(($) => $.back, { ns: 'login' })}</span>
</button>
</div>
)
diff --git a/web/app/signup/components/input-mail.spec.tsx b/web/app/(auth)/signup/components/input-mail.spec.tsx
similarity index 100%
rename from web/app/signup/components/input-mail.spec.tsx
rename to web/app/(auth)/signup/components/input-mail.spec.tsx
diff --git a/web/app/signup/components/input-mail.tsx b/web/app/(auth)/signup/components/input-mail.tsx
similarity index 98%
rename from web/app/signup/components/input-mail.tsx
rename to web/app/(auth)/signup/components/input-mail.tsx
index dc4c6a65e16..ba03f0ea994 100644
--- a/web/app/signup/components/input-mail.tsx
+++ b/web/app/(auth)/signup/components/input-mail.tsx
@@ -6,7 +6,7 @@ import { Input } from '@langgenius/dify-ui/input'
import { useMutation, useSuspenseQuery } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
import { useLocale } from '#i18n'
-import Split from '@/app/signin/split'
+import Split from '@/app/(auth)/signin/split'
import { emailRegex } from '@/config'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import Link from '@/next/link'
diff --git a/web/app/signup/layout.tsx b/web/app/(auth)/signup/layout.tsx
similarity index 73%
rename from web/app/signup/layout.tsx
rename to web/app/(auth)/signup/layout.tsx
index faf0c054fd2..4d6d34a1159 100644
--- a/web/app/signup/layout.tsx
+++ b/web/app/(auth)/signup/layout.tsx
@@ -1,10 +1,9 @@
import { getRouteMetadata } from '@/app/route-metadata'
-import SignupLayout from './signup-layout'
export function generateMetadata() {
return getRouteMetadata('login', ($) => $['signup.createAccount'])
}
export default function RegisterLayout({ children }: { children: React.ReactNode }) {
- return <SignupLayout>{children}</SignupLayout>
+ return children
}
diff --git a/web/app/signup/page.tsx b/web/app/(auth)/signup/page.tsx
similarity index 100%
rename from web/app/signup/page.tsx
rename to web/app/(auth)/signup/page.tsx
diff --git a/web/app/signup/set-password/__tests__/page.spec.tsx b/web/app/(auth)/signup/set-password/__tests__/page.spec.tsx
similarity index 100%
rename from web/app/signup/set-password/__tests__/page.spec.tsx
rename to web/app/(auth)/signup/set-password/__tests__/page.spec.tsx
diff --git a/web/app/signup/set-password/layout.tsx b/web/app/(auth)/signup/set-password/layout.tsx
similarity index 100%
rename from web/app/signup/set-password/layout.tsx
rename to web/app/(auth)/signup/set-password/layout.tsx
diff --git a/web/app/(auth)/signup/set-password/page.tsx b/web/app/(auth)/signup/set-password/page.tsx
new file mode 100644
index 00000000000..c1c9e0dc0bc
--- /dev/null
+++ b/web/app/(auth)/signup/set-password/page.tsx
@@ -0,0 +1,199 @@
+'use client'
+import type { FormActions } from '@langgenius/dify-ui/form'
+import { Button } from '@langgenius/dify-ui/button'
+import {
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
+ FieldValidity,
+} from '@langgenius/dify-ui/field'
+import { Form } from '@langgenius/dify-ui/form'
+import {
+ PasswordField,
+ PasswordFieldInput,
+ PasswordFieldToggle,
+} from '@langgenius/dify-ui/password-field'
+import { useMutation, useQueryClient } from '@tanstack/react-query'
+import Cookies from 'js-cookie'
+import { useCallback, useRef } from 'react'
+import { useTranslation } from 'react-i18next'
+import { useLocale } from '#i18n'
+import { resolvePostLoginRedirect } from '@/app/(auth)/signin/utils/post-login-redirect'
+import { rememberRegistrationSuccess } from '@/app/components/base/amplitude/registration-tracking'
+import { validPassword } from '@/config'
+import useDocumentTitle from '@/hooks/use-document-title'
+import { useRouter, useSearchParams } from '@/next/navigation'
+import { consoleQuery } from '@/service/console'
+import { rememberCreateAppExternalAttribution } from '@/utils/create-app-tracking'
+import { sendGAEvent } from '@/utils/gtag'
+import { replaceLoginRedirect } from '@/utils/login-redirect.client'
+import { getBrowserTimezone } from '@/utils/timezone'
+import { basePath } from '@/utils/var'
+
+type PasswordFormValues = {
+ password: string
+ confirmPassword: string
+}
+
+const parseUtmInfo = () => {
+ const utmInfoStr = Cookies.get('utm_info')
+ if (!utmInfoStr) return null
+ try {
+ return JSON.parse(utmInfoStr)
+ } catch (e) {
+ console.error('Failed to parse utm_info cookie:', e)
+ return null
+ }
+}
+
+const ChangePasswordForm = () => {
+ const { t } = useTranslation(['common', 'login', 'accountSettings'])
+ const router = useRouter()
+ const queryClient = useQueryClient()
+ const searchParams = useSearchParams()
+ const token = decodeURIComponent(searchParams.get('token') || '')
+ const locale = useLocale()
+
+ const formActionsRef = useRef<FormActions>(null)
+ const confirmPasswordRef = useRef<HTMLInputElement>(null)
+ const { mutateAsync: register, isPending } = useMutation(
+ consoleQuery.emailRegister.post.mutationOptions(),
+ )
+ const pageTitle = t(($) => $.changePassword, { ns: 'login' })
+ useDocumentTitle(pageTitle)
+
+ const handleSubmit = useCallback(
+ async (formValues: PasswordFormValues) => {
+ if (isPending) return
+ try {
+ const res = await register({
+ body: {
+ token,
+ new_password: formValues.password,
+ password_confirm: formValues.confirmPassword,
+ language: locale,
+ timezone: getBrowserTimezone(),
+ },
+ })
+ const { result } = res
+ if (result === 'success') {
+ const utmInfo = parseUtmInfo()
+ rememberCreateAppExternalAttribution({ utmInfo })
+ // Defer the Amplitude event until the user ID is attached. The app context
+ // external sync replays it after setUserId runs once the redirect lands on /apps.
+ // Firing it here would record it under an anonymous Amplitude profile.
+ rememberRegistrationSuccess({ method: 'email', utmInfo })
+
+ sendGAEvent(
+ utmInfo ? 'user_registration_success_with_utm' : 'user_registration_success',
+ {
+ method: 'email',
+ ...utmInfo,
+ },
+ )
+ Cookies.remove('utm_info') // Clean up: remove utm_info cookie
+
+ await queryClient.resetQueries({ queryKey: consoleQuery.account.profile.get.key() })
+ replaceLoginRedirect(resolvePostLoginRedirect(searchParams), router.replace, basePath)
+ }
+ } catch (error) {
+ console.error(error)
+ }
+ },
+ [token, register, locale, queryClient, router, searchParams, isPending],
+ )
+
+ return (
+ <div className="flex flex-col">
+ <div className="mx-auto w-full">
+ <h1 className="title-4xl-semi-bold text-text-primary">{pageTitle}</h1>
+ <p className="mt-2 body-md-regular text-text-secondary">
+ {t(($) => $.changePasswordTip, { ns: 'login' })}
+ </p>
+ </div>
+
+ <div className="mx-auto mt-6 w-full">
+ <Form<PasswordFormValues>
+ actionsRef={formActionsRef}
+ onFormSubmit={(formValues) => void handleSubmit(formValues)}
+ >
+ <Field
+ name="password"
+ validate={(value) => {
+ const passwordValue = String(value)
+ if (!passwordValue.trim()) return t(($) => $['error.passwordEmpty'], { ns: 'login' })
+ return validPassword.test(passwordValue)
+ ? null
+ : t(($) => $['error.passwordInvalid'], { ns: 'login' })
+ }}
+ className="mb-5"
+ >
+ <FieldLabel>{t(($) => $['account.newPassword'], { ns: 'accountSettings' })}</FieldLabel>
+ <PasswordField>
+ <PasswordFieldInput
+ required
+ autoComplete="new-password"
+ onValueChange={() => {
+ if (confirmPasswordRef.current?.value)
+ formActionsRef.current?.validate('confirmPassword')
+ }}
+ placeholder={t(($) => $.passwordPlaceholder, { ns: 'login' })}
+ />
+ <PasswordFieldToggle aria-label={t(($) => $.showPassword, { ns: 'login' })} />
+ </PasswordField>
+ <FieldValidity>
+ {({ validity }) =>
+ validity.valid !== false ? (
+ <FieldDescription>
+ {t(($) => $['error.passwordInvalid'], { ns: 'login' })}
+ </FieldDescription>
+ ) : null
+ }
+ </FieldValidity>
+ <FieldValidity>
+ {({ validity }) => (
+ <FieldError>
+ {t(
+ ($) =>
+ $[validity.valueMissing ? 'error.passwordEmpty' : 'error.passwordInvalid'],
+ { ns: 'login' },
+ )}
+ </FieldError>
+ )}
+ </FieldValidity>
+ </Field>
+ <Field
+ name="confirmPassword"
+ validate={(value, formValues) => {
+ const confirmationValue = String(value)
+ return !confirmationValue || confirmationValue === formValues.password
+ ? null
+ : t(($) => $['account.notEqual'], { ns: 'accountSettings' })
+ }}
+ className="mb-5"
+ >
+ <FieldLabel>
+ {t(($) => $['account.confirmPassword'], { ns: 'accountSettings' })}
+ </FieldLabel>
+ <PasswordField>
+ <PasswordFieldInput
+ required
+ autoComplete="new-password"
+ ref={confirmPasswordRef}
+ placeholder={t(($) => $.confirmPasswordPlaceholder, { ns: 'login' })}
+ />
+ <PasswordFieldToggle aria-label={t(($) => $.showPassword, { ns: 'login' })} />
+ </PasswordField>
+ <FieldError>{t(($) => $['account.notEqual'], { ns: 'accountSettings' })}</FieldError>
+ </Field>
+ <Button type="submit" variant="primary" className="w-full" loading={isPending}>
+ {t(($) => $.changePasswordBtn, { ns: 'login' })}
+ </Button>
+ </Form>
+ </div>
+ </div>
+ )
+}
+
+export default ChangePasswordForm
diff --git a/web/app/(shareLayout)/webapp-reset-password/layout.tsx b/web/app/(shareLayout)/webapp-reset-password/layout.tsx
index c0f876f1eef..e557c270e10 100644
--- a/web/app/(shareLayout)/webapp-reset-password/layout.tsx
+++ b/web/app/(shareLayout)/webapp-reset-password/layout.tsx
@@ -1,10 +1,10 @@
+import { AuthShell } from '@/app/components/auth-shell'
import { getRouteMetadata } from '@/app/route-metadata'
-import ResetPasswordLayout from './reset-password-layout'
export function generateMetadata() {
return getRouteMetadata('login', ($) => $.resetPassword)
}
-export default function SignInLayout({ children }: { children: React.ReactNode }) {
- return <ResetPasswordLayout>{children}</ResetPasswordLayout>
+export default function WebappResetPasswordLayout({ children }: { children: React.ReactNode }) {
+ return <AuthShell>{children}</AuthShell>
}
diff --git a/web/app/(shareLayout)/webapp-reset-password/reset-password-layout.tsx b/web/app/(shareLayout)/webapp-reset-password/reset-password-layout.tsx
deleted file mode 100644
index 45b89afd820..00000000000
--- a/web/app/(shareLayout)/webapp-reset-password/reset-password-layout.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-'use client'
-import { cn } from '@langgenius/dify-ui/cn'
-import { useSuspenseQuery } from '@tanstack/react-query'
-import Header from '@/app/signin/_header'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-
-export default function ResetPasswordLayout({ children }: { children: React.ReactNode }) {
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
-
- return (
- <div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
- <div
- className={cn(
- 'flex w-full shrink-0 flex-col rounded-2xl border border-effects-highlight bg-background-default-subtle',
- )}
- >
- <Header />
- <div
- className={cn(
- 'flex w-full grow flex-col items-center justify-center',
- 'px-6',
- 'md:px-27',
- )}
- >
- <div className="flex w-100 flex-col">{children}</div>
- </div>
- {!systemFeatures.branding.enabled && (
- <div className="px-8 py-6 system-xs-regular text-text-tertiary">
- © {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
- </div>
- )}
- </div>
- </div>
- )
-}
diff --git a/web/app/(shareLayout)/webapp-reset-password/set-password/page.tsx b/web/app/(shareLayout)/webapp-reset-password/set-password/page.tsx
index d43564fd843..a7f29fec0f8 100644
--- a/web/app/(shareLayout)/webapp-reset-password/set-password/page.tsx
+++ b/web/app/(shareLayout)/webapp-reset-password/set-password/page.tsx
@@ -86,11 +86,9 @@ const ChangePasswordForm = () => {
}, [password, token, valid, confirmPassword])
return (
- <div
- className={cn('flex w-full grow flex-col items-center justify-center', 'px-6', 'md:px-27')}
- >
+ <>
{!showSuccess && (
- <div className="flex flex-col md:w-100">
+ <div className="flex flex-col">
<div className="mx-auto w-full">
<h1 className="title-4xl-semi-bold text-text-primary">
{t(($) => $.changePassword, { ns: 'login' })}
@@ -143,7 +141,7 @@ const ChangePasswordForm = () => {
</div>
)}
{showSuccess && (
- <div className="flex flex-col md:w-100">
+ <div className="flex flex-col">
<div className="mx-auto w-full">
<div className="mb-3 flex size-14 items-center justify-center rounded-2xl border border-components-panel-border-subtle font-bold shadow-lg">
<RiCheckboxCircleFill aria-hidden="true" className="size-6 text-text-success" />
@@ -163,7 +161,7 @@ const ChangePasswordForm = () => {
</div>
</div>
)}
- </div>
+ </>
)
}
diff --git a/web/app/(shareLayout)/webapp-signin/layout.tsx b/web/app/(shareLayout)/webapp-signin/layout.tsx
index 6fcbbb17de5..9c84bf39c35 100644
--- a/web/app/(shareLayout)/webapp-signin/layout.tsx
+++ b/web/app/(shareLayout)/webapp-signin/layout.tsx
@@ -1,37 +1,17 @@
'use client'
import type { PropsWithChildren } from 'react'
-import { cn } from '@langgenius/dify-ui/cn'
-import { useSuspenseQuery } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
+import { AuthShell } from '@/app/components/auth-shell'
import useDocumentTitle from '@/hooks/use-document-title'
-export default function SignInLayout({ children }: PropsWithChildren) {
+export default function WebappSignInLayout({ children }: PropsWithChildren) {
const { t } = useTranslation(['login'])
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
useDocumentTitle(t(($) => $['webapp.login'], { ns: 'login' }))
+
return (
- <>
- <div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
- <div
- className={cn(
- 'flex w-full shrink-0 flex-col rounded-2xl border border-effects-highlight bg-background-default-subtle',
- )}
- >
- {/* <Header /> */}
- <div
- className={cn('flex w-full grow flex-col items-center justify-center px-6 md:px-27')}
- >
- <div className="flex justify-center md:w-110 lg:w-150">{children}</div>
- </div>
- {systemFeatures.branding.enabled === false && (
- <div className="px-8 py-6 system-xs-regular text-text-tertiary">
- © {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
- </div>
- )}
- </div>
- </div>
- </>
+ <AuthShell header={false} wide>
+ {children}
+ </AuthShell>
)
}
diff --git a/web/app/(shareLayout)/webapp-signin/normalForm.tsx b/web/app/(shareLayout)/webapp-signin/normalForm.tsx
index 326dbeb14dc..f65003795d8 100644
--- a/web/app/(shareLayout)/webapp-signin/normalForm.tsx
+++ b/web/app/(shareLayout)/webapp-signin/normalForm.tsx
@@ -1,6 +1,5 @@
'use client'
import { zLicenseStatus } from '@dify/contracts/api/console/system-features/zod.gen'
-import { cn } from '@langgenius/dify-ui/cn'
import { RiContractLine, RiDoorLockLine, RiErrorWarningFill } from '@remixicon/react'
import { useSuspenseQuery } from '@tanstack/react-query'
import * as React from 'react'
@@ -51,13 +50,7 @@ const NormalForm = () => {
init()
}, [init])
if (isLoading) {
- return (
- <div
- className={cn('flex w-full grow flex-col items-center justify-center', 'px-6', 'md:px-27')}
- >
- <LoadingPlaceholder />
- </div>
- )
+ return <LoadingPlaceholder />
}
if (systemFeatures.license?.status === zLicenseStatus.enum.lost) {
return (
@@ -66,7 +59,7 @@ const NormalForm = () => {
<div className="rounded-lg bg-linear-to-r from-workflow-workflow-progress-bg-1 to-workflow-workflow-progress-bg-2 p-4">
<div className="relative mb-2 flex size-10 items-center justify-center rounded-xl bg-components-card-bg shadow">
<RiContractLine className="size-5" />
- <RiErrorWarningFill className="absolute -top-1 -right-1 size-4 text-text-warning-secondary" />
+ <RiErrorWarningFill className="absolute -inset-e-1 -top-1 size-4 text-text-warning-secondary" />
</div>
<p className="system-sm-medium text-text-primary">
{t(($) => $.licenseLost, { ns: 'login' })}
@@ -86,7 +79,7 @@ const NormalForm = () => {
<div className="rounded-lg bg-linear-to-r from-workflow-workflow-progress-bg-1 to-workflow-workflow-progress-bg-2 p-4">
<div className="relative mb-2 flex size-10 items-center justify-center rounded-xl bg-components-card-bg shadow">
<RiContractLine className="size-5" />
- <RiErrorWarningFill className="absolute -top-1 -right-1 size-4 text-text-warning-secondary" />
+ <RiErrorWarningFill className="absolute -inset-e-1 -top-1 size-4 text-text-warning-secondary" />
</div>
<p className="system-sm-medium text-text-primary">
{t(($) => $.licenseExpired, { ns: 'login' })}
@@ -106,7 +99,7 @@ const NormalForm = () => {
<div className="rounded-lg bg-linear-to-r from-workflow-workflow-progress-bg-1 to-workflow-workflow-progress-bg-2 p-4">
<div className="relative mb-2 flex size-10 items-center justify-center rounded-xl bg-components-card-bg shadow">
<RiContractLine className="size-5" />
- <RiErrorWarningFill className="absolute -top-1 -right-1 size-4 text-text-warning-secondary" />
+ <RiErrorWarningFill className="absolute -inset-e-1 -top-1 size-4 text-text-warning-secondary" />
</div>
<p className="system-sm-medium text-text-primary">
{t(($) => $.licenseInactive, { ns: 'login' })}
diff --git a/web/app/__tests__/route-metadata.spec.ts b/web/app/__tests__/route-metadata.spec.ts
index a85569332f0..10511eb6f85 100644
--- a/web/app/__tests__/route-metadata.spec.ts
+++ b/web/app/__tests__/route-metadata.spec.ts
@@ -1,20 +1,20 @@
+import { generateMetadata as generateInitMetadata } from '../(auth)/init/page'
+import { generateMetadata as generateInstallMetadata } from '../(auth)/install/layout'
+import { generateMetadata as generateCheckCodeMetadata } from '../(auth)/reset-password/check-code/layout'
+import { generateMetadata as generateResetPasswordMetadata } from '../(auth)/reset-password/layout'
+import { generateMetadata as generateSetPasswordMetadata } from '../(auth)/reset-password/set-password/layout'
+import { generateMetadata as generateSignInCheckCodeMetadata } from '../(auth)/signin/check-code/layout'
+import { generateMetadata as generateSignInMetadata } from '../(auth)/signin/page'
+import { generateMetadata as generateSignupCheckCodeMetadata } from '../(auth)/signup/check-code/layout'
+import { generateMetadata as generateSignupMetadata } from '../(auth)/signup/layout'
+import { generateMetadata as generateSignupSetPasswordMetadata } from '../(auth)/signup/set-password/layout'
import { generateMetadata as generateAgentsMetadata } from '../(commonLayout)/agents/page'
import { generateMetadata as generateAppsMetadata } from '../(commonLayout)/apps/page'
import { generateMetadata as generateHomeMetadata } from '../(commonLayout)/page'
import { generateMetadata as generateWebappCheckCodeMetadata } from '../(shareLayout)/webapp-reset-password/check-code/layout'
import { generateMetadata as generateWebappResetPasswordMetadata } from '../(shareLayout)/webapp-reset-password/layout'
import { generateMetadata as generateWebappSetPasswordMetadata } from '../(shareLayout)/webapp-reset-password/set-password/layout'
-import { generateMetadata as generateInitMetadata } from '../init/page'
-import { generateMetadata as generateInstallMetadata } from '../install/layout'
import { generateMetadata as generateOAuthCallbackMetadata } from '../oauth-callback/layout'
-import { generateMetadata as generateCheckCodeMetadata } from '../reset-password/check-code/layout'
-import { generateMetadata as generateResetPasswordMetadata } from '../reset-password/layout'
-import { generateMetadata as generateSetPasswordMetadata } from '../reset-password/set-password/layout'
-import { generateMetadata as generateSignInCheckCodeMetadata } from '../signin/check-code/layout'
-import { generateMetadata as generateSignInMetadata } from '../signin/page'
-import { generateMetadata as generateSignupCheckCodeMetadata } from '../signup/check-code/layout'
-import { generateMetadata as generateSignupMetadata } from '../signup/layout'
-import { generateMetadata as generateSignupSetPasswordMetadata } from '../signup/set-password/layout'
vi.mock('server-only', () => ({}))
@@ -23,13 +23,8 @@ vi.mock('@/i18n/server', async (importOriginal) => ({
getLocaleOnServer: async () => 'en-US',
}))
-vi.mock('../reset-password/reset-password-layout', () => ({ default: () => null }))
-vi.mock('../signin/sign-in-page', () => ({ default: () => null }))
-vi.mock('../signup/signup-layout', () => ({ default: () => null }))
-vi.mock('../(shareLayout)/webapp-reset-password/reset-password-layout', () => ({
- default: () => null,
-}))
-vi.mock('../init/InitPasswordPopup', () => ({ default: () => null }))
+vi.mock('../(auth)/signin/sign-in-page', () => ({ default: () => null }))
+vi.mock('../(auth)/init/InitPasswordPopup', () => ({ default: () => null }))
vi.mock('@/app/components/apps', () => ({ Apps: () => null }))
vi.mock('@/features/agent-v2/roster/page', () => ({ default: () => null }))
vi.mock('@/features/home/page', () => ({ HomePage: () => null }))
diff --git a/web/app/account/oauth/authorize/layout.tsx b/web/app/account/oauth/authorize/layout.tsx
deleted file mode 100644
index a2817995324..00000000000
--- a/web/app/account/oauth/authorize/layout.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-'use client'
-import type { ReactNode } from 'react'
-import { useSuspenseQuery } from '@tanstack/react-query'
-import { OAuthRegistrationAnalytics } from '@/app/components/oauth-registration-analytics'
-import Header from '@/app/signin/_header'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-
-type Props = {
- children: ReactNode
-}
-
-const copyrightYear = new Date().getFullYear()
-
-export default function OAuthAuthorizeLayout({ children }: Props) {
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
-
- return (
- <div className="flex min-h-screen w-full justify-center bg-background-default-burn p-6">
- <OAuthRegistrationAnalytics />
- <div className="flex w-full shrink-0 flex-col items-center rounded-2xl border border-effects-highlight bg-background-default-subtle">
- <Header />
- <div className="flex w-full grow flex-col items-center justify-center px-6 md:px-27">
- <div className="flex flex-col md:w-100">{children}</div>
- </div>
- {systemFeatures.branding.enabled === false && (
- <div className="px-8 py-6 system-xs-regular text-text-tertiary">
- © {copyrightYear} LangGenius, Inc. All rights reserved.
- </div>
- )}
- </div>
- </div>
- )
-}
diff --git a/web/app/activate/page.tsx b/web/app/activate/page.tsx
deleted file mode 100644
index 4707ccc1bee..00000000000
--- a/web/app/activate/page.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-'use client'
-import { cn } from '@langgenius/dify-ui/cn'
-import { useSuspenseQuery } from '@tanstack/react-query'
-import * as React from 'react'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import Header from '../signin/_header'
-import ActivateForm from './activateForm'
-
-const Activate = () => {
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
- return (
- <div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
- <div
- className={cn(
- 'flex w-full shrink-0 flex-col rounded-2xl border border-effects-highlight bg-background-default-subtle',
- )}
- >
- <Header />
- <ActivateForm />
- {!systemFeatures.branding.enabled && (
- <div className="px-8 py-6 text-sm font-normal text-text-tertiary">
- © {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
- </div>
- )}
- </div>
- </div>
- )
-}
-
-export default Activate
diff --git a/web/app/signin/__tests__/_header.spec.tsx b/web/app/components/auth-shell/__tests__/header.spec.tsx
similarity index 98%
rename from web/app/signin/__tests__/_header.spec.tsx
rename to web/app/components/auth-shell/__tests__/header.spec.tsx
index 737daaac6c6..9559c219e42 100644
--- a/web/app/signin/__tests__/_header.spec.tsx
+++ b/web/app/components/auth-shell/__tests__/header.spec.tsx
@@ -3,7 +3,7 @@ import userEvent from '@testing-library/user-event'
import { setLocaleOnClient } from '@/i18n/client'
import { renderWithConsoleQuery as render } from '@/test/console/query-data'
import { createDeferred } from '@/test/deferred'
-import Header from '../_header'
+import Header from '../header'
vi.mock('@/i18n/client', () => ({
setLocaleOnClient: vi.fn(),
diff --git a/web/app/signin/__tests__/layout.spec.tsx b/web/app/components/auth-shell/__tests__/index.spec.tsx
similarity index 54%
rename from web/app/signin/__tests__/layout.spec.tsx
rename to web/app/components/auth-shell/__tests__/index.spec.tsx
index 653233dea47..9b18b573a02 100644
--- a/web/app/signin/__tests__/layout.spec.tsx
+++ b/web/app/components/auth-shell/__tests__/index.spec.tsx
@@ -1,17 +1,17 @@
import { screen, within } from '@testing-library/react'
import { renderWithConsoleQuery as render } from '@/test/console/query-data'
-import SignInLayout from '../layout'
+import { AuthShell } from '..'
vi.mock('@/next/navigation', () => ({
useRouter: () => ({ refresh: vi.fn() }),
}))
-describe('SignInLayout landmarks', () => {
- it('separates the site header, sign-in content, and copyright', () => {
+describe('AuthShell', () => {
+ it('separates the site header, page content, and copyright', () => {
render(
- <SignInLayout>
+ <AuthShell>
<h1>Sign in</h1>
- </SignInLayout>,
+ </AuthShell>,
{ systemFeatures: { branding: { enabled: false } } },
)
@@ -22,4 +22,17 @@ describe('SignInLayout landmarks', () => {
expect(main).not.toContainElement(screen.getByRole('banner'))
expect(main).not.toContainElement(screen.getByRole('contentinfo'))
})
+
+ it('omits the header when asked and the copyright under custom branding', () => {
+ render(
+ <AuthShell header={false}>
+ <h1>Sign in</h1>
+ </AuthShell>,
+ { systemFeatures: { branding: { enabled: true } } },
+ )
+
+ expect(screen.getByRole('main')).toBeInTheDocument()
+ expect(screen.queryByRole('banner')).not.toBeInTheDocument()
+ expect(screen.queryByRole('contentinfo')).not.toBeInTheDocument()
+ })
})
diff --git a/web/app/signin/__tests__/_locale-menu.spec.tsx b/web/app/components/auth-shell/__tests__/locale-menu.spec.tsx
similarity index 95%
rename from web/app/signin/__tests__/_locale-menu.spec.tsx
rename to web/app/components/auth-shell/__tests__/locale-menu.spec.tsx
index 2594d4b1710..1d44bef07a0 100644
--- a/web/app/signin/__tests__/_locale-menu.spec.tsx
+++ b/web/app/components/auth-shell/__tests__/locale-menu.spec.tsx
@@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
-import LocaleMenu from '../_locale-menu'
+import LocaleMenu from '../locale-menu'
const localeItems = [
{ value: 'en-US', name: 'English (US)' },
diff --git a/web/app/signin/_header.tsx b/web/app/components/auth-shell/header.tsx
similarity index 96%
rename from web/app/signin/_header.tsx
rename to web/app/components/auth-shell/header.tsx
index 94660760d90..c9876a4299a 100644
--- a/web/app/signin/_header.tsx
+++ b/web/app/components/auth-shell/header.tsx
@@ -8,7 +8,7 @@ import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import { setLocaleOnClient } from '@/i18n/client'
import { languages } from '@/i18n/language'
import { useRouter } from '@/next/navigation'
-import LocaleMenu from './_locale-menu'
+import LocaleMenu from './locale-menu'
const ThemeSelector = dynamic(() => import('@/app/components/base/theme-selector'), {
ssr: false,
@@ -40,7 +40,7 @@ const Header = () => {
router.refresh()
}}
/>
- <Separator decorative orientation="vertical" className="mx-0 ml-2 h-4" />
+ <Separator decorative orientation="vertical" className="mx-0 ms-2 h-4" />
<ThemeSelector />
</div>
</header>
diff --git a/web/app/components/auth-shell/index.tsx b/web/app/components/auth-shell/index.tsx
new file mode 100644
index 00000000000..3e36b6e1a84
--- /dev/null
+++ b/web/app/components/auth-shell/index.tsx
@@ -0,0 +1,40 @@
+'use client'
+
+import type { ReactNode } from 'react'
+import { useSuspenseQuery } from '@tanstack/react-query'
+import { systemFeaturesQueryOptions } from '@/features/system-features/client'
+import Header from './header'
+
+type AuthShellProps = {
+ children: ReactNode
+ header?: boolean
+ wide?: boolean
+}
+
+const copyrightYear = new Date().getFullYear()
+
+export function AuthShell({ children, header = true, wide = false }: AuthShellProps) {
+ const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
+
+ return (
+ <div className="flex min-h-screen w-full justify-center bg-background-default-burn p-6">
+ <div className="flex w-full min-w-0 flex-col items-center rounded-2xl border border-effects-highlight bg-background-default-subtle">
+ {header && <Header />}
+ <main className="flex w-full grow flex-col items-center justify-center px-6 md:px-27">
+ <div
+ className={
+ wide ? 'flex justify-center md:w-110 lg:w-150' : 'flex w-full flex-col md:w-100'
+ }
+ >
+ {children}
+ </div>
+ </main>
+ {!systemFeatures.branding.enabled && (
+ <footer className="px-8 py-6 system-xs-regular text-text-tertiary">
+ © {copyrightYear} LangGenius, Inc. All rights reserved.
+ </footer>
+ )}
+ </div>
+ </div>
+ )
+}
diff --git a/web/app/signin/_locale-menu.tsx b/web/app/components/auth-shell/locale-menu.tsx
similarity index 91%
rename from web/app/signin/_locale-menu.tsx
rename to web/app/components/auth-shell/locale-menu.tsx
index aae7f4a9c83..c566e51cf71 100644
--- a/web/app/signin/_locale-menu.tsx
+++ b/web/app/components/auth-shell/locale-menu.tsx
@@ -26,9 +26,9 @@ export default function LocaleMenu<T extends string>({
const selectedItem = items.find((item) => item.value === value)
return (
- <div className="w-56 text-right">
+ <div className="w-56 text-end">
<Menu>
- <div className="relative inline-block text-left">
+ <div className="relative inline-block text-start">
<div>
<MenuTrigger
render={
@@ -38,7 +38,7 @@ export default function LocaleMenu<T extends string>({
/>
}
>
- <span className="mr-1 i-heroicons-globe-alt size-5" aria-hidden="true" />
+ <span className="me-1 i-heroicons-globe-alt size-5" aria-hidden="true" />
{selectedItem?.name}
</MenuTrigger>
</div>
diff --git a/web/app/device/_header.tsx b/web/app/device/_header.tsx
deleted file mode 100644
index 41ffa75158e..00000000000
--- a/web/app/device/_header.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-'use client'
-import { Separator } from '@langgenius/dify-ui/separator'
-import { useSuspenseQuery } from '@tanstack/react-query'
-import dynamic from 'next/dynamic'
-import { useLocale } from '#i18n'
-import { DifyLogo } from '@/app/components/base/logo/dify-logo'
-import LocaleMenu from '@/app/signin/_locale-menu'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import { setLocaleOnClient } from '@/i18n/client'
-import { languages } from '@/i18n/language'
-
-const ThemeSelector = dynamic(() => import('@/app/components/base/theme-selector'), {
- ssr: false,
- loading: () => <div className="size-8 bg-transparent" />,
-})
-
-const Header = () => {
- const locale = useLocale()
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
-
- return (
- <div className="flex w-full items-center justify-between p-6">
- {systemFeatures.branding.enabled && systemFeatures.branding.login_page_logo ? (
- <img
- src={systemFeatures.branding.login_page_logo}
- className="block h-7 w-auto object-contain"
- alt="logo"
- />
- ) : (
- <DifyLogo alt="Dify" size="large" />
- )}
- <div className="flex items-center gap-1">
- <LocaleMenu
- value={locale}
- items={languages.filter((item) => item.supported)}
- onChange={(value) => {
- setLocaleOnClient(value)
- }}
- />
- <Separator decorative orientation="vertical" className="mx-0 ml-2 h-4" />
- <ThemeSelector />
- </div>
- </div>
- )
-}
-
-export default Header
diff --git a/web/app/device/layout.tsx b/web/app/device/layout.tsx
deleted file mode 100644
index 39f2894ccff..00000000000
--- a/web/app/device/layout.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-'use client'
-import { cn } from '@langgenius/dify-ui/cn'
-import { useSuspenseQuery } from '@tanstack/react-query'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import Header from './_header'
-
-export default function DeviceLayout({ children }: { children: React.ReactNode }) {
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
- return (
- <div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
- <div
- className={cn(
- 'flex w-full shrink-0 flex-col items-center rounded-2xl border border-effects-highlight bg-background-default-subtle',
- )}
- >
- <Header />
- <div className={cn('flex w-full grow flex-col items-center justify-center px-6 md:px-27')}>
- <div className="flex flex-col md:w-100">{children}</div>
- </div>
- {systemFeatures.branding.enabled === false && (
- <div className="px-8 py-6 system-xs-regular text-text-tertiary">
- © {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
- </div>
- )}
- </div>
- </div>
- )
-}
diff --git a/web/app/forgot-password/page.tsx b/web/app/forgot-password/page.tsx
deleted file mode 100644
index 891714a88be..00000000000
--- a/web/app/forgot-password/page.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-'use client'
-import { cn } from '@langgenius/dify-ui/cn'
-import { useSuspenseQuery } from '@tanstack/react-query'
-import * as React from 'react'
-import ChangePasswordForm from '@/app/forgot-password/ChangePasswordForm'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import { useSearchParams } from '@/next/navigation'
-import Header from '../signin/_header'
-import ForgotPasswordForm from './ForgotPasswordForm'
-
-const ForgotPassword = () => {
- const searchParams = useSearchParams()
- const token = searchParams.get('token')
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
-
- return (
- <div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
- <div
- className={cn(
- 'flex w-full shrink-0 flex-col rounded-2xl border border-effects-highlight bg-background-default-subtle',
- )}
- >
- <Header />
- {token ? <ChangePasswordForm /> : <ForgotPasswordForm />}
- {!systemFeatures.branding.enabled && (
- <div className="px-8 py-6 text-sm font-normal text-text-tertiary">
- © {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
- </div>
- )}
- </div>
- </div>
- )
-}
-
-export default ForgotPassword
diff --git a/web/app/init/page.tsx b/web/app/init/page.tsx
deleted file mode 100644
index 8507c53a9ea..00000000000
--- a/web/app/init/page.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { cn } from '@langgenius/dify-ui/cn'
-import * as React from 'react'
-import { getRouteMetadata } from '@/app/route-metadata'
-import InitPasswordPopup from './InitPasswordPopup'
-
-export function generateMetadata() {
- return getRouteMetadata('login', ($) => $.adminInitPassword)
-}
-
-const Install = () => {
- return (
- <div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
- <div
- className={cn(
- 'flex w-full shrink-0 flex-col rounded-2xl border border-effects-highlight bg-background-default-subtle',
- )}
- >
- <div className="m-auto block w-96">
- <InitPasswordPopup />
- </div>
- </div>
- </div>
- )
-}
-
-export default Install
diff --git a/web/app/install/page.tsx b/web/app/install/page.tsx
deleted file mode 100644
index 510f8808836..00000000000
--- a/web/app/install/page.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-'use client'
-import { cn } from '@langgenius/dify-ui/cn'
-import { useSuspenseQuery } from '@tanstack/react-query'
-import * as React from 'react'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import Header from '../signin/_header'
-import InstallForm from './installForm'
-
-const Install = () => {
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
- return (
- <div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
- <div
- className={cn(
- 'flex w-full shrink-0 flex-col rounded-2xl border border-effects-highlight bg-background-default-subtle',
- )}
- >
- <Header />
- <InstallForm />
- {!systemFeatures.branding.enabled && (
- <div className="mt-auto px-8 py-6 text-sm font-normal text-text-tertiary">
- © {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
- </div>
- )}
- </div>
- </div>
- )
-}
-
-export default Install
diff --git a/web/app/reset-password/reset-password-layout.tsx b/web/app/reset-password/reset-password-layout.tsx
deleted file mode 100644
index 6266deafe10..00000000000
--- a/web/app/reset-password/reset-password-layout.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-'use client'
-import { cn } from '@langgenius/dify-ui/cn'
-import { useSuspenseQuery } from '@tanstack/react-query'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import Header from '../signin/_header'
-
-export default function ResetPasswordLayout({ children }: { children: React.ReactNode }) {
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
-
- return (
- <div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
- <div
- className={cn(
- 'flex w-full shrink-0 flex-col rounded-2xl border border-effects-highlight bg-background-default-subtle',
- )}
- >
- <Header />
- <div
- className={cn(
- 'flex w-full grow flex-col items-center justify-center',
- 'px-6',
- 'md:px-27',
- )}
- >
- <div className="flex flex-col md:w-100">{children}</div>
- </div>
- {!systemFeatures.branding.enabled && (
- <div className="px-8 py-6 system-xs-regular text-text-tertiary">
- © {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
- </div>
- )}
- </div>
- </div>
- )
-}
diff --git a/web/app/signin/layout.tsx b/web/app/signin/layout.tsx
deleted file mode 100644
index 385c9faf96a..00000000000
--- a/web/app/signin/layout.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-'use client'
-import { cn } from '@langgenius/dify-ui/cn'
-import { useSuspenseQuery } from '@tanstack/react-query'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import Header from './_header'
-
-export default function SignInLayout({ children }: { children: React.ReactNode }) {
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
- return (
- <>
- <div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
- <div
- className={cn(
- 'flex w-full min-w-0 flex-col items-center rounded-2xl border border-effects-highlight bg-background-default-subtle',
- )}
- >
- <Header />
- <main
- className={cn('flex w-full grow flex-col items-center justify-center px-6 md:px-27')}
- >
- <div className="flex w-full flex-col md:w-100">{children}</div>
- </main>
- {systemFeatures.branding.enabled === false && (
- <footer className="px-8 py-6 system-xs-regular text-text-tertiary">
- © {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
- </footer>
- )}
- </div>
- </div>
- </>
- )
-}
diff --git a/web/app/signup/set-password/page.tsx b/web/app/signup/set-password/page.tsx
deleted file mode 100644
index c6af1249c84..00000000000
--- a/web/app/signup/set-password/page.tsx
+++ /dev/null
@@ -1,207 +0,0 @@
-'use client'
-import type { FormActions } from '@langgenius/dify-ui/form'
-import { Button } from '@langgenius/dify-ui/button'
-import { cn } from '@langgenius/dify-ui/cn'
-import {
- Field,
- FieldDescription,
- FieldError,
- FieldLabel,
- FieldValidity,
-} from '@langgenius/dify-ui/field'
-import { Form } from '@langgenius/dify-ui/form'
-import {
- PasswordField,
- PasswordFieldInput,
- PasswordFieldToggle,
-} from '@langgenius/dify-ui/password-field'
-import { useMutation, useQueryClient } from '@tanstack/react-query'
-import Cookies from 'js-cookie'
-import { useCallback, useRef } from 'react'
-import { useTranslation } from 'react-i18next'
-import { useLocale } from '#i18n'
-import { rememberRegistrationSuccess } from '@/app/components/base/amplitude/registration-tracking'
-import { resolvePostLoginRedirect } from '@/app/signin/utils/post-login-redirect'
-import { validPassword } from '@/config'
-import useDocumentTitle from '@/hooks/use-document-title'
-import { useRouter, useSearchParams } from '@/next/navigation'
-import { consoleQuery } from '@/service/console'
-import { rememberCreateAppExternalAttribution } from '@/utils/create-app-tracking'
-import { sendGAEvent } from '@/utils/gtag'
-import { replaceLoginRedirect } from '@/utils/login-redirect.client'
-import { getBrowserTimezone } from '@/utils/timezone'
-import { basePath } from '@/utils/var'
-
-type PasswordFormValues = {
- password: string
- confirmPassword: string
-}
-
-const parseUtmInfo = () => {
- const utmInfoStr = Cookies.get('utm_info')
- if (!utmInfoStr) return null
- try {
- return JSON.parse(utmInfoStr)
- } catch (e) {
- console.error('Failed to parse utm_info cookie:', e)
- return null
- }
-}
-
-const ChangePasswordForm = () => {
- const { t } = useTranslation(['common', 'login', 'accountSettings'])
- const router = useRouter()
- const queryClient = useQueryClient()
- const searchParams = useSearchParams()
- const token = decodeURIComponent(searchParams.get('token') || '')
- const locale = useLocale()
-
- const formActionsRef = useRef<FormActions>(null)
- const confirmPasswordRef = useRef<HTMLInputElement>(null)
- const { mutateAsync: register, isPending } = useMutation(
- consoleQuery.emailRegister.post.mutationOptions(),
- )
- const pageTitle = t(($) => $.changePassword, { ns: 'login' })
- useDocumentTitle(pageTitle)
-
- const handleSubmit = useCallback(
- async (formValues: PasswordFormValues) => {
- if (isPending) return
- try {
- const res = await register({
- body: {
- token,
- new_password: formValues.password,
- password_confirm: formValues.confirmPassword,
- language: locale,
- timezone: getBrowserTimezone(),
- },
- })
- const { result } = res
- if (result === 'success') {
- const utmInfo = parseUtmInfo()
- rememberCreateAppExternalAttribution({ utmInfo })
- // Defer the Amplitude event until the user ID is attached. The app context
- // external sync replays it after setUserId runs once the redirect lands on /apps.
- // Firing it here would record it under an anonymous Amplitude profile.
- rememberRegistrationSuccess({ method: 'email', utmInfo })
-
- sendGAEvent(
- utmInfo ? 'user_registration_success_with_utm' : 'user_registration_success',
- {
- method: 'email',
- ...utmInfo,
- },
- )
- Cookies.remove('utm_info') // Clean up: remove utm_info cookie
-
- await queryClient.resetQueries({ queryKey: consoleQuery.account.profile.get.key() })
- replaceLoginRedirect(resolvePostLoginRedirect(searchParams), router.replace, basePath)
- }
- } catch (error) {
- console.error(error)
- }
- },
- [token, register, locale, queryClient, router, searchParams, isPending],
- )
-
- return (
- <div
- className={cn('flex w-full grow flex-col items-center justify-center', 'px-6', 'md:px-27')}
- >
- <div className="flex flex-col md:w-100">
- <div className="mx-auto w-full">
- <h1 className="title-4xl-semi-bold text-text-primary">{pageTitle}</h1>
- <p className="mt-2 body-md-regular text-text-secondary">
- {t(($) => $.changePasswordTip, { ns: 'login' })}
- </p>
- </div>
-
- <div className="mx-auto mt-6 w-full">
- <Form<PasswordFormValues>
- actionsRef={formActionsRef}
- onFormSubmit={(formValues) => void handleSubmit(formValues)}
- >
- <Field
- name="password"
- validate={(value) => {
- const passwordValue = String(value)
- if (!passwordValue.trim())
- return t(($) => $['error.passwordEmpty'], { ns: 'login' })
- return validPassword.test(passwordValue)
- ? null
- : t(($) => $['error.passwordInvalid'], { ns: 'login' })
- }}
- className="mb-5"
- >
- <FieldLabel>
- {t(($) => $['account.newPassword'], { ns: 'accountSettings' })}
- </FieldLabel>
- <PasswordField>
- <PasswordFieldInput
- required
- autoComplete="new-password"
- onValueChange={() => {
- if (confirmPasswordRef.current?.value)
- formActionsRef.current?.validate('confirmPassword')
- }}
- placeholder={t(($) => $.passwordPlaceholder, { ns: 'login' })}
- />
- <PasswordFieldToggle aria-label={t(($) => $.showPassword, { ns: 'login' })} />
- </PasswordField>
- <FieldValidity>
- {({ validity }) =>
- validity.valid !== false ? (
- <FieldDescription>
- {t(($) => $['error.passwordInvalid'], { ns: 'login' })}
- </FieldDescription>
- ) : null
- }
- </FieldValidity>
- <FieldValidity>
- {({ validity }) => (
- <FieldError>
- {t(
- ($) =>
- $[validity.valueMissing ? 'error.passwordEmpty' : 'error.passwordInvalid'],
- { ns: 'login' },
- )}
- </FieldError>
- )}
- </FieldValidity>
- </Field>
- <Field
- name="confirmPassword"
- validate={(value, formValues) => {
- const confirmationValue = String(value)
- return !confirmationValue || confirmationValue === formValues.password
- ? null
- : t(($) => $['account.notEqual'], { ns: 'accountSettings' })
- }}
- className="mb-5"
- >
- <FieldLabel>
- {t(($) => $['account.confirmPassword'], { ns: 'accountSettings' })}
- </FieldLabel>
- <PasswordField>
- <PasswordFieldInput
- required
- autoComplete="new-password"
- ref={confirmPasswordRef}
- placeholder={t(($) => $.confirmPasswordPlaceholder, { ns: 'login' })}
- />
- <PasswordFieldToggle aria-label={t(($) => $.showPassword, { ns: 'login' })} />
- </PasswordField>
- <FieldError>{t(($) => $['account.notEqual'], { ns: 'accountSettings' })}</FieldError>
- </Field>
- <Button type="submit" variant="primary" className="w-full" loading={isPending}>
- {t(($) => $.changePasswordBtn, { ns: 'login' })}
- </Button>
- </Form>
- </div>
- </div>
- </div>
- )
-}
-
-export default ChangePasswordForm
diff --git a/web/app/signup/signup-layout.tsx b/web/app/signup/signup-layout.tsx
deleted file mode 100644
index 6852d5456fb..00000000000
--- a/web/app/signup/signup-layout.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-'use client'
-import { cn } from '@langgenius/dify-ui/cn'
-import { useSuspenseQuery } from '@tanstack/react-query'
-import Header from '@/app/signin/_header'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-
-export default function SignupLayout({ children }: { children: React.ReactNode }) {
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
-
- return (
- <div className={cn('flex min-h-screen w-full justify-center bg-background-default-burn p-6')}>
- <div
- className={cn(
- 'flex w-full shrink-0 flex-col items-center rounded-2xl border border-effects-highlight bg-background-default-subtle',
- )}
- >
- <Header />
- <div className={cn('flex w-full grow flex-col items-center justify-center px-6 md:px-27')}>
- <div className="flex flex-col md:w-100">{children}</div>
- </div>
- {systemFeatures.branding.enabled === false && (
- <div className="px-8 py-6 system-xs-regular text-text-tertiary">
- © {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
- </div>
- )}
- </div>
- </div>
- )
-}