feat(auth): add admin password reset CLI command and reset password web UI (#347)

* feat(auth): add admin password reset CLI command and reset password web UI

* fix(auth): invalidate previous reset tokens and use AsyncLocalStorage for link capture
This commit is contained in:
Yiling-J
2026-08-25 14:35:33 +08:00
committed by GitHub
parent 8801d59b2e
commit 470a4bd6f7
43 changed files with 1361 additions and 6 deletions
+5
View File
@@ -80,6 +80,11 @@ USER root
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Expose "bun index.js" as "shumai" CLI command (and alias "shuami")
RUN printf '#!/bin/sh\nexec bun /app/index.js "$@"\n' > /usr/local/bin/shumai \
&& chmod +x /usr/local/bin/shumai \
&& ln -s /usr/local/bin/shumai /usr/local/bin/shuami
ENTRYPOINT ["docker-entrypoint.sh"]
# Default command: run migrations and start API server
+2
View File
@@ -56,6 +56,8 @@ apps/web/e2e/
|---|---|
| Sign up as the first user and become the team owner | `tests/auth/signup.spec.ts` |
| Log in with existing credentials | `tests/auth/login.spec.ts` |
| Show error when accessing reset-password page without token | `tests/auth/reset-password.spec.ts` |
| Reset password with valid token and allow logging in with new password | `tests/auth/reset-password.spec.ts` |
### team
| Test | File |
@@ -0,0 +1,63 @@
import { expect, test } from '../../fixtures'
import { apiSignup, E2E_PASSWORD, uniqueEmail } from '../../helpers/auth'
import { loginViaUi } from '../../helpers/ui'
test('should show error when accessing reset-password page without token', async ({ page }) => {
await page.goto('/reset-password')
await expect(page.getByText('Invalid or missing reset token.')).toBeVisible()
await expect(page.getByRole('button', { name: 'Go to Login' })).toBeVisible()
})
test('should reset password with valid token and allow logging in with new password', async ({
page,
request,
prisma,
}) => {
const email = uniqueEmail('reset-pw')
const oldPassword = E2E_PASSWORD
const newPassword = 'newSecretPassword123'
// 1. Seed user
await apiSignup(request, email, oldPassword)
// 2. Request password reset via API
const resetRes = await request.post('/api/auth/request-password-reset', {
data: {
email,
redirectTo: '/reset-password',
},
})
expect(resetRes.ok()).toBe(true)
// Retrieve the generated verification token from DB
const verification = await prisma.verification.findFirst({
where: {
identifier: { startsWith: 'reset-password:' },
},
orderBy: { createdAt: 'desc' },
})
expect(verification).not.toBeNull()
const token = verification!.identifier.replace('reset-password:', '')
// 3. Open reset password page with token
await page.goto(`/reset-password?token=${token}`)
// 4. Fill in new password and confirmation
await page.locator('input#password').fill(newPassword)
await page.locator('input#confirmPassword').fill(newPassword)
// 5. Submit form
await page.getByRole('button', { name: 'Reset Password' }).click()
// 6. Verify success state
await expect(page.getByText('Password reset successfully!')).toBeVisible()
// 7. Click Go to Login
await page.getByRole('button', { name: 'Go to Login' }).click()
await expect(page).toHaveURL('/login')
// 8. Log in with the new password
await loginViaUi(page, email, newPassword)
await expect(page).toHaveURL(/\/teams\/[^/]+/)
await expect(page.getByRole('heading', { name: 'Projects' })).toBeVisible()
})
+25
View File
@@ -13,12 +13,37 @@ import { initTranscodeWorkflows } from '@shumai/transcode'
import { workflowService } from '@shumai/workflow-core'
import { handleDaemonCommands } from '@shumai/core/src/utils/daemon'
import { authService } from '@shumai/core/src/auth/auth'
if (process.argv.includes('--check')) {
console.log('✅ Web app evaluated successfully!')
process.exit(0)
}
const cliArgs = process.argv.slice(2)
const resetCmdIndex = cliArgs.findIndex(
(arg) => arg === 'reset-password' || arg === 'reset-passowrd',
)
if (resetCmdIndex !== -1) {
const email = cliArgs[resetCmdIndex + 1]
if (!email || email.startsWith('-')) {
console.error('Error: Please provide a valid email address.')
console.error('Usage: shumai reset-password <email>')
process.exit(1)
}
try {
const link = await authService.generatePasswordResetLink(email)
console.log(link)
process.exit(0)
} catch (err: unknown) {
const message = err instanceof Error ? err.message : 'Unknown error'
console.error(`Error: ${message}`)
process.exit(1)
}
}
async function run() {
// Initialize workflows and activities for local executor mode
initAgentWorkflows()
+5 -1
View File
@@ -52,7 +52,11 @@
},
{
"group": "Team Settings",
"pages": ["using-shumai/transcode-settings", "using-shumai/quotas-settings"]
"pages": [
"using-shumai/transcode-settings",
"using-shumai/quotas-settings",
"using-shumai/password-reset"
]
},
{
"group": "Configuration",
+60
View File
@@ -0,0 +1,60 @@
---
title: Password Reset
description: How administrators generate secure password reset links for team members.
---
Because Shumai does not require an external email delivery service (SMTP) to be configured for standard self-hosted deployments, password resets are initiated securely by an administrator using the Shumai CLI.
---
## Overview
When a user forgets their password, an administrator can generate a one-time password reset link directly from the command line.
- **Link Expiration**: The generated password reset link is valid for **1 hour** (`3600 seconds`).
- **One-Time Use**: Once used, the token is permanently invalidated.
- **Session Revocation**: When a user resets their password, all existing active sessions for that account are automatically revoked across all devices.
- **Latest Link Validity**: Generating a new reset link for a user immediately supersedes any previously generated pending links.
---
## Generating a Password Reset Link
### Running on Local Host / Server
Run the `reset-password` subcommand from your Shumai installation directory:
```bash
shumai reset-password <user-email>
```
_(Alternatively, `bun apps/web/src/index.ts reset-password <user-email>`)_
**Example Output:**
```text
http://localhost:3000/reset-password?token=bb3xg4uO3cwN0FQv4cgUK6Hh
```
### Running inside Docker
If Shumai is running inside a Docker container, execute the command using `docker exec`:
```bash
docker exec -it <container-name-or-id> shumai reset-password <user-email>
```
> [!TIP]
> Both `shumai` and the common alias `shuami` (e.g. `shuami reset-password <user-email>`) are supported.
> [!NOTE]
> For remote servers or production deployments, ensure `BETTER_AUTH_URL` is set in your environment (e.g., `BETTER_AUTH_URL=https://shumai.example.com`) so the CLI generates the reset link with your public domain instead of `localhost`.
---
## Member Reset Experience
1. The administrator sends the generated URL to the team member via their preferred secure communication channel.
2. The user opens the link in their browser.
3. The user inputs their **New Password** and **Confirm Password** (minimum 3 characters).
4. Upon clicking **Reset Password**, the password is securely updated, all previous active sessions are invalidated, and the user is redirected to `/login` to sign in.
+212 -1
View File
@@ -1,7 +1,7 @@
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
import { prisma } from '@shumai/db'
import { setupTestDbHooks } from '@shumai/db/test'
import { auth } from './auth'
import { auth, authService } from './auth'
import { userMetadataService } from '../user-metadata/user-metadata'
import { teamService } from '@shumai/core/src/team/team'
@@ -93,3 +93,214 @@ describe('Auth Signup Locale Hook', () => {
}
})
})
describe('AuthService Password Reset', () => {
setupTestDbHooks()
beforeEach(() => {
vi.spyOn(teamService, 'getSignupInfo').mockResolvedValue({
initialized: false,
demoMode: false,
userCount: 1,
})
})
it('should throw error when generating reset link for non-existent user', async () => {
await expect(authService.generatePasswordResetLink('nonexistent@example.com')).rejects.toThrow(
'User with email "nonexistent@example.com" not found',
)
})
it('should generate a valid reset link and invalidate previous pending tokens', async () => {
const email = `reset-user-${Date.now()}@example.com`
const signUpRes = await auth.api.signUpEmail({
headers: new Headers(),
body: {
email,
password: 'initialPassword123',
name: 'Reset User',
},
})
const userId = signUpRes.user.id
const firstLink = await authService.generatePasswordResetLink(email)
expect(firstLink).toContain('/reset-password?token=')
const firstToken = new URL(firstLink).searchParams.get('token')!
expect(firstToken).toBeTruthy()
// Check that verification record exists with identifier: reset-password:<token> and value: userId
const firstVerification = await prisma.verification.findFirst({
where: { identifier: `reset-password:${firstToken}` },
})
expect(firstVerification).not.toBeNull()
expect(firstVerification?.value).toBe(userId)
// Generating a second link should produce a new token and invalidate the first token
const secondLink = await authService.generatePasswordResetLink(email)
const secondToken = new URL(secondLink).searchParams.get('token')!
expect(secondToken).not.toBe(firstToken)
const newVerification = await prisma.verification.findFirst({
where: { identifier: `reset-password:${secondToken}` },
})
expect(newVerification).not.toBeNull()
expect(newVerification?.value).toBe(userId)
// The first token's verification record must have been deleted
const oldVerification = await prisma.verification.findFirst({
where: { identifier: `reset-password:${firstToken}` },
})
expect(oldVerification).toBeNull()
// First token must fail to reset password
await expect(
authService.resetPassword(firstToken, 'newPasswordFromFirstToken'),
).rejects.toThrow()
// Second token must succeed
const resetRes = await authService.resetPassword(secondToken, 'newPasswordFromSecondToken')
expect(resetRes.success).toBe(true)
})
it('should reset password with valid token and revoke active sessions', async () => {
const email = `reset-valid-${Date.now()}@example.com`
const signUpRes = await auth.api.signUpEmail({
headers: new Headers(),
body: {
email,
password: 'oldPassword123',
name: 'Valid Reset User',
},
})
const userId = signUpRes.user.id
// Create an active session
await prisma.session.create({
data: {
userId,
token: `session-${Date.now()}`,
expiresAt: new Date(Date.now() + 86400 * 1000),
},
})
const activeSessionsBefore = await prisma.session.findMany({
where: { userId },
})
expect(activeSessionsBefore.length).toBeGreaterThan(0)
// Generate reset link
const link = await authService.generatePasswordResetLink(email)
const token = new URL(link).searchParams.get('token')!
// Reset password
const result = await authService.resetPassword(token, 'newPassword456')
expect(result.success).toBe(true)
// Verify active sessions are revoked
const activeSessionsAfter = await prisma.session.findMany({
where: { userId },
})
expect(activeSessionsAfter.length).toBe(0)
// Verify token was deleted
const usedToken = await prisma.verification.findFirst({
where: { identifier: `reset-password:${token}` },
})
expect(usedToken).toBeNull()
// Verify user password was updated to new password
const account = await prisma.account.findFirst({
where: { userId, providerId: 'credential' },
})
expect(account).toBeDefined()
expect(account?.password).toBeTruthy()
const { verifyPassword } = await import('better-auth/crypto')
const isNewValid = await verifyPassword({
hash: account!.password!,
password: 'newPassword456',
})
expect(isNewValid).toBe(true)
const isOldValid = await verifyPassword({
hash: account!.password!,
password: 'oldPassword123',
})
expect(isOldValid).toBe(false)
})
it('should reject expired or invalid token', async () => {
const email = `reset-expired-${Date.now()}@example.com`
const user = await prisma.user.create({
data: {
email,
name: 'Expired User',
},
})
// Create expired token fixture with identifier: reset-password:<token> and value: userId
const token = 'expired-token-123'
await prisma.verification.create({
data: {
identifier: `reset-password:${token}`,
value: user.id,
expiresAt: new Date(Date.now() - 1000), // Expired 1 second ago
},
})
await expect(authService.resetPassword(token, 'newPassword123')).rejects.toThrow()
// Non-existent token
await expect(
authService.resetPassword('non-existent-token', 'newPassword123'),
).rejects.toThrow()
})
it('should handle concurrent link generation for different users without crosstalk', async () => {
const emailA = `concurrent-a-${Date.now()}@example.com`
const emailB = `concurrent-b-${Date.now()}@example.com`
const [resA, resB] = await Promise.all([
auth.api.signUpEmail({
headers: new Headers(),
body: { email: emailA, password: 'passwordA123', name: 'User A' },
}),
auth.api.signUpEmail({
headers: new Headers(),
body: { email: emailB, password: 'passwordB123', name: 'User B' },
}),
])
const [linkA, linkB] = await Promise.all([
authService.generatePasswordResetLink(emailA),
authService.generatePasswordResetLink(emailB),
])
const tokenA = new URL(linkA).searchParams.get('token')!
const tokenB = new URL(linkB).searchParams.get('token')!
expect(tokenA).toBeTruthy()
expect(tokenB).toBeTruthy()
expect(tokenA).not.toBe(tokenB)
const verificationA = await prisma.verification.findFirst({
where: { identifier: `reset-password:${tokenA}` },
})
const verificationB = await prisma.verification.findFirst({
where: { identifier: `reset-password:${tokenB}` },
})
expect(verificationA?.value).toBe(resA.user.id)
expect(verificationB?.value).toBe(resB.user.id)
// Reset both passwords concurrently
const [resetResA, resetResB] = await Promise.all([
authService.resetPassword(tokenA, 'newPasswordA123'),
authService.resetPassword(tokenB, 'newPasswordB123'),
])
expect(resetResA.success).toBe(true)
expect(resetResB.success).toBe(true)
})
})
+96
View File
@@ -1,3 +1,4 @@
import { AsyncLocalStorage } from 'node:async_hooks'
import { betterAuth } from 'better-auth'
import { prismaAdapter } from 'better-auth/adapters/prisma'
import { prisma } from '@shumai/db'
@@ -6,6 +7,13 @@ import { inviteService } from '@shumai/core/src/invite/invite'
import { createAuthMiddleware } from 'better-auth/api'
import { userMetadataService } from '@shumai/core/src/user-metadata/user-metadata'
interface GeneratedResetLink {
url: string
token: string
}
const resetLinkStorage = new AsyncLocalStorage<GeneratedResetLink>()
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: 'postgresql',
@@ -13,6 +21,15 @@ export const auth = betterAuth({
emailAndPassword: {
enabled: true,
minPasswordLength: 3,
revokeSessionsOnPasswordReset: true,
resetPasswordTokenExpiresIn: 3600,
sendResetPassword: async ({ url, token }) => {
const store = resetLinkStorage.getStore()
if (store) {
store.url = url
store.token = token
}
},
},
secret: process.env.BETTER_AUTH_SECRET,
// eslint-disable-next-line @typescript-eslint/naming-convention
@@ -122,3 +139,82 @@ export const auth = betterAuth({
}),
},
})
export class AuthService {
constructor(private readonly prismaClient: typeof prisma = prisma) {}
async generatePasswordResetLink(email: string): Promise<string> {
const user = await this.prismaClient.user.findUnique({
where: { email },
})
if (!user) {
throw new Error(`User with email "${email}" not found`)
}
const context: GeneratedResetLink = { url: '', token: '' }
await resetLinkStorage.run(context, async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const res = await (auth.api.requestPasswordReset as any)({
headers: new Headers(),
body: {
email,
redirectTo: '/reset-password',
},
})
if (res?.error) {
throw new Error(res.error.message || 'Failed to generate reset link')
}
})
if (context.token) {
// Invalidate any other pending reset tokens for this user
await this.prismaClient.verification.deleteMany({
where: {
value: user.id,
identifier: {
startsWith: 'reset-password:',
not: `reset-password:${context.token}`,
},
},
})
const rawBaseUrl =
process.env.BETTER_AUTH_URL ||
`http://localhost:${process.env.SHUMAI_SERVER_PORT || '3000'}`
const baseUrl = rawBaseUrl.replace(/\/$/, '')
return `${baseUrl}/reset-password?token=${context.token}`
}
throw new Error('Failed to generate reset link')
}
async resetPassword(token: string, newPassword: string): Promise<{ success: boolean }> {
if (!token || !token.trim()) {
throw new Error('Token is required')
}
if (!newPassword || newPassword.length < 3) {
throw new Error('Password must be at least 3 characters')
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const res = await (auth.api.resetPassword as any)({
headers: new Headers(),
body: {
token,
newPassword,
password: newPassword,
},
})
if (res?.error) {
throw new Error(res.error.message || 'Failed to reset password')
}
return { success: true }
}
}
export const authService = new AuthService()
@@ -22,13 +22,14 @@ test.describe('audio player e2e', () => {
await vp.clickPlayToggle()
await expect.poll(() => vp.isPaused(), { timeout: 5_000 }).toBe(false)
// Wait for 300ms. If the playhead froze (which happened under the bug where
// Wait for playhead to advance. If the playhead froze (which happened under the bug where
// it waited 1000ms for rVFC grace period), readoutFrame would still be 0.
// With the fix, the playhead should advance immediately.
await page.waitForTimeout(300)
await expect
.poll(async () => (await vp.snapshot()).readoutFrame, { timeout: 5_000 })
.toBeGreaterThan(0)
const afterPlay = await vp.snapshot()
expect(afterPlay.readoutFrame).toBeGreaterThan(0)
expect(afterPlay.currentTime).toBeGreaterThan(0)
})
})
+1 -1
View File
@@ -5,4 +5,4 @@ export const authClient = createAuthClient({
baseURL: window.location.origin,
})
export const { signIn, signUp, useSession, signOut } = authClient
export const { signIn, signUp, useSession, signOut, resetPassword } = authClient
+13
View File
@@ -51,6 +51,19 @@
"first_user_notice": "You will be the owner of the default workspace as the first user!",
"password_min_placeholder": "At least 3 characters",
"invite_join_message": "{inviterName} invited you to join {targetName} as {role}.",
"reset_password": "Reset Password",
"reset_password_subtitle": "Enter your new password below.",
"new_password": "New Password",
"confirm_password": "Confirm Password",
"new_password_placeholder": "Enter new password",
"confirm_password_placeholder": "Confirm new password",
"passwords_do_not_match": "Passwords do not match",
"resetting_password": "Resetting password...",
"password_reset_success": "Password reset successfully!",
"password_reset_success_description": "You will be redirected to the login page shortly.",
"invalid_reset_token": "Invalid or missing reset token.",
"invalid_reset_token_description": "Please contact your administrator to generate a new password reset link.",
"go_to_login": "Go to Login",
"cancel": "Cancel",
"create": "Create",
+13
View File
@@ -51,6 +51,19 @@
"first_user_notice": "作为第一位用户,您将成为默认工作空间的拥有者!",
"password_min_placeholder": "至少 3 个字符",
"invite_join_message": "{inviterName} 邀请您加入 {targetName},角色为 {role}。",
"reset_password": "重置密码",
"reset_password_subtitle": "请在下方输入您的新密码。",
"new_password": "新密码",
"confirm_password": "确认密码",
"new_password_placeholder": "输入新密码",
"confirm_password_placeholder": "确认新密码",
"passwords_do_not_match": "两次输入的密码不一致",
"resetting_password": "正在重置密码...",
"password_reset_success": "密码重置成功!",
"password_reset_success_description": "您将很快被重定向到登录页面。",
"invalid_reset_token": "无效或缺失的重置令牌。",
"invalid_reset_token_description": "请联系管理员生成新的密码重置链接。",
"go_to_login": "前往登录",
"cancel": "取消",
"create": "创建",
+13
View File
@@ -47,6 +47,19 @@ export * from "./registration_disabled_description.js";
export * from "./first_user_notice.js";
export * from "./password_min_placeholder.js";
export * from "./invite_join_message.js";
export * from "./reset_password.js";
export * from "./reset_password_subtitle.js";
export * from "./new_password.js";
export * from "./confirm_password.js";
export * from "./new_password_placeholder.js";
export * from "./confirm_password_placeholder.js";
export * from "./passwords_do_not_match.js";
export * from "./resetting_password.js";
export * from "./password_reset_success.js";
export * from "./password_reset_success_description.js";
export * from "./invalid_reset_token.js";
export * from "./invalid_reset_token_description.js";
export * from "./go_to_login.js";
export * from "./cancel.js";
export * from "./create.js";
export * from "./save.js";
+13
View File
@@ -49,6 +49,19 @@ export * from './registration_disabled_description.js'
export * from './first_user_notice.js'
export * from './password_min_placeholder.js'
export * from './invite_join_message.js'
export * from './reset_password.js'
export * from './reset_password_subtitle.js'
export * from './new_password.js'
export * from './confirm_password.js'
export * from './new_password_placeholder.js'
export * from './confirm_password_placeholder.js'
export * from './passwords_do_not_match.js'
export * from './resetting_password.js'
export * from './password_reset_success.js'
export * from './password_reset_success_description.js'
export * from './invalid_reset_token.js'
export * from './invalid_reset_token_description.js'
export * from './go_to_login.js'
export * from './cancel.js'
export * from './create.js'
export * from './save.js'
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Confirm Password" |
*
* @param {Confirm_PasswordInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const confirm_password: ((inputs?: Confirm_PasswordInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Confirm_PasswordInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Confirm_PasswordInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Confirm_PasswordInputs */
const en_confirm_password = /** @type {(inputs: Confirm_PasswordInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Confirm Password`)
};
const zh_confirm_password = /** @type {(inputs: Confirm_PasswordInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`确认密码`)
};
/**
* | output |
* | --- |
* | "Confirm Password" |
*
* @param {Confirm_PasswordInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const confirm_password = /** @type {((inputs?: Confirm_PasswordInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Confirm_PasswordInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_confirm_password(inputs)
return zh_confirm_password(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Confirm new password" |
*
* @param {Confirm_Password_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const confirm_password_placeholder: ((inputs?: Confirm_Password_PlaceholderInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Confirm_Password_PlaceholderInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Confirm_Password_PlaceholderInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Confirm_Password_PlaceholderInputs */
const en_confirm_password_placeholder = /** @type {(inputs: Confirm_Password_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Confirm new password`)
};
const zh_confirm_password_placeholder = /** @type {(inputs: Confirm_Password_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`确认新密码`)
};
/**
* | output |
* | --- |
* | "Confirm new password" |
*
* @param {Confirm_Password_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const confirm_password_placeholder = /** @type {((inputs?: Confirm_Password_PlaceholderInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Confirm_Password_PlaceholderInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_confirm_password_placeholder(inputs)
return zh_confirm_password_placeholder(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Go to Login" |
*
* @param {Go_To_LoginInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const go_to_login: ((inputs?: Go_To_LoginInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Go_To_LoginInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Go_To_LoginInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Go_To_LoginInputs */
const en_go_to_login = /** @type {(inputs: Go_To_LoginInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Go to Login`)
};
const zh_go_to_login = /** @type {(inputs: Go_To_LoginInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`前往登录`)
};
/**
* | output |
* | --- |
* | "Go to Login" |
*
* @param {Go_To_LoginInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const go_to_login = /** @type {((inputs?: Go_To_LoginInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Go_To_LoginInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_go_to_login(inputs)
return zh_go_to_login(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Invalid or missing reset token." |
*
* @param {Invalid_Reset_TokenInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const invalid_reset_token: ((inputs?: Invalid_Reset_TokenInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Invalid_Reset_TokenInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Invalid_Reset_TokenInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Invalid_Reset_TokenInputs */
const en_invalid_reset_token = /** @type {(inputs: Invalid_Reset_TokenInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Invalid or missing reset token.`)
};
const zh_invalid_reset_token = /** @type {(inputs: Invalid_Reset_TokenInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`无效或缺失的重置令牌。`)
};
/**
* | output |
* | --- |
* | "Invalid or missing reset token." |
*
* @param {Invalid_Reset_TokenInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const invalid_reset_token = /** @type {((inputs?: Invalid_Reset_TokenInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Invalid_Reset_TokenInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_invalid_reset_token(inputs)
return zh_invalid_reset_token(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Please contact your administrator to generate a new password reset link." |
*
* @param {Invalid_Reset_Token_DescriptionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const invalid_reset_token_description: ((inputs?: Invalid_Reset_Token_DescriptionInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Invalid_Reset_Token_DescriptionInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Invalid_Reset_Token_DescriptionInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Invalid_Reset_Token_DescriptionInputs */
const en_invalid_reset_token_description = /** @type {(inputs: Invalid_Reset_Token_DescriptionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Please contact your administrator to generate a new password reset link.`)
};
const zh_invalid_reset_token_description = /** @type {(inputs: Invalid_Reset_Token_DescriptionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`请联系管理员生成新的密码重置链接。`)
};
/**
* | output |
* | --- |
* | "Please contact your administrator to generate a new password reset link." |
*
* @param {Invalid_Reset_Token_DescriptionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const invalid_reset_token_description = /** @type {((inputs?: Invalid_Reset_Token_DescriptionInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Invalid_Reset_Token_DescriptionInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_invalid_reset_token_description(inputs)
return zh_invalid_reset_token_description(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "New Password" |
*
* @param {New_PasswordInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const new_password: ((inputs?: New_PasswordInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<New_PasswordInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type New_PasswordInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} New_PasswordInputs */
const en_new_password = /** @type {(inputs: New_PasswordInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`New Password`)
};
const zh_new_password = /** @type {(inputs: New_PasswordInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`新密码`)
};
/**
* | output |
* | --- |
* | "New Password" |
*
* @param {New_PasswordInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const new_password = /** @type {((inputs?: New_PasswordInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<New_PasswordInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_new_password(inputs)
return zh_new_password(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Enter new password" |
*
* @param {New_Password_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const new_password_placeholder: ((inputs?: New_Password_PlaceholderInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<New_Password_PlaceholderInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type New_Password_PlaceholderInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} New_Password_PlaceholderInputs */
const en_new_password_placeholder = /** @type {(inputs: New_Password_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Enter new password`)
};
const zh_new_password_placeholder = /** @type {(inputs: New_Password_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`输入新密码`)
};
/**
* | output |
* | --- |
* | "Enter new password" |
*
* @param {New_Password_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const new_password_placeholder = /** @type {((inputs?: New_Password_PlaceholderInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<New_Password_PlaceholderInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_new_password_placeholder(inputs)
return zh_new_password_placeholder(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Password reset successfully!" |
*
* @param {Password_Reset_SuccessInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const password_reset_success: ((inputs?: Password_Reset_SuccessInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Password_Reset_SuccessInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Password_Reset_SuccessInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Password_Reset_SuccessInputs */
const en_password_reset_success = /** @type {(inputs: Password_Reset_SuccessInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Password reset successfully!`)
};
const zh_password_reset_success = /** @type {(inputs: Password_Reset_SuccessInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`密码重置成功!`)
};
/**
* | output |
* | --- |
* | "Password reset successfully!" |
*
* @param {Password_Reset_SuccessInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const password_reset_success = /** @type {((inputs?: Password_Reset_SuccessInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Password_Reset_SuccessInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_password_reset_success(inputs)
return zh_password_reset_success(inputs)
});
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "You will be redirected to the login page shortly." |
*
* @param {Password_Reset_Success_DescriptionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const password_reset_success_description: ((inputs?: Password_Reset_Success_DescriptionInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Password_Reset_Success_DescriptionInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Password_Reset_Success_DescriptionInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Password_Reset_Success_DescriptionInputs */
const en_password_reset_success_description = /** @type {(inputs: Password_Reset_Success_DescriptionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`You will be redirected to the login page shortly.`)
};
const zh_password_reset_success_description = /** @type {(inputs: Password_Reset_Success_DescriptionInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`您将很快被重定向到登录页面。`)
};
/**
* | output |
* | --- |
* | "You will be redirected to the login page shortly." |
*
* @param {Password_Reset_Success_DescriptionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const password_reset_success_description = /** @type {((inputs?: Password_Reset_Success_DescriptionInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Password_Reset_Success_DescriptionInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_password_reset_success_description(inputs)
return zh_password_reset_success_description(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Passwords do not match" |
*
* @param {Passwords_Do_Not_MatchInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const passwords_do_not_match: ((inputs?: Passwords_Do_Not_MatchInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Passwords_Do_Not_MatchInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Passwords_Do_Not_MatchInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Passwords_Do_Not_MatchInputs */
const en_passwords_do_not_match = /** @type {(inputs: Passwords_Do_Not_MatchInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Passwords do not match`)
};
const zh_passwords_do_not_match = /** @type {(inputs: Passwords_Do_Not_MatchInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`两次输入的密码不一致`)
};
/**
* | output |
* | --- |
* | "Passwords do not match" |
*
* @param {Passwords_Do_Not_MatchInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const passwords_do_not_match = /** @type {((inputs?: Passwords_Do_Not_MatchInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Passwords_Do_Not_MatchInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_passwords_do_not_match(inputs)
return zh_passwords_do_not_match(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Reset Password" |
*
* @param {Reset_PasswordInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const reset_password: ((inputs?: Reset_PasswordInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Reset_PasswordInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Reset_PasswordInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Reset_PasswordInputs */
const en_reset_password = /** @type {(inputs: Reset_PasswordInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Reset Password`)
};
const zh_reset_password = /** @type {(inputs: Reset_PasswordInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`重置密码`)
};
/**
* | output |
* | --- |
* | "Reset Password" |
*
* @param {Reset_PasswordInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const reset_password = /** @type {((inputs?: Reset_PasswordInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Reset_PasswordInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_reset_password(inputs)
return zh_reset_password(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Enter your new password below." |
*
* @param {Reset_Password_SubtitleInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const reset_password_subtitle: ((inputs?: Reset_Password_SubtitleInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Reset_Password_SubtitleInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Reset_Password_SubtitleInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Reset_Password_SubtitleInputs */
const en_reset_password_subtitle = /** @type {(inputs: Reset_Password_SubtitleInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Enter your new password below.`)
};
const zh_reset_password_subtitle = /** @type {(inputs: Reset_Password_SubtitleInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`请在下方输入您的新密码。`)
};
/**
* | output |
* | --- |
* | "Enter your new password below." |
*
* @param {Reset_Password_SubtitleInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const reset_password_subtitle = /** @type {((inputs?: Reset_Password_SubtitleInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Reset_Password_SubtitleInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_reset_password_subtitle(inputs)
return zh_reset_password_subtitle(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Resetting password..." |
*
* @param {Resetting_PasswordInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const resetting_password: ((inputs?: Resetting_PasswordInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Resetting_PasswordInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Resetting_PasswordInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Resetting_PasswordInputs */
const en_resetting_password = /** @type {(inputs: Resetting_PasswordInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Resetting password...`)
};
const zh_resetting_password = /** @type {(inputs: Resetting_PasswordInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`正在重置密码...`)
};
/**
* | output |
* | --- |
* | "Resetting password..." |
*
* @param {Resetting_PasswordInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const resetting_password = /** @type {((inputs?: Resetting_PasswordInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Resetting_PasswordInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_resetting_password(inputs)
return zh_resetting_password(inputs)
});
+21
View File
@@ -10,6 +10,7 @@
import { Route as rootRouteImport } from './routes/__root'
import { Route as SignupRouteImport } from './routes/signup'
import { Route as ResetPasswordRouteImport } from './routes/reset-password'
import { Route as LoginRouteImport } from './routes/login'
import { Route as IndexRouteImport } from './routes/index'
import { Route as ShareShareIdRouteImport } from './routes/share/$shareId'
@@ -36,6 +37,11 @@ const SignupRoute = SignupRouteImport.update({
path: '/signup',
getParentRoute: () => rootRouteImport,
} as any)
const ResetPasswordRoute = ResetPasswordRouteImport.update({
id: '/reset-password',
path: '/reset-password',
getParentRoute: () => rootRouteImport,
} as any).lazy(() => import('./routes/reset-password.lazy').then((d) => d.Route))
const LoginRoute = LoginRouteImport.update({
id: '/login',
path: '/login',
@@ -154,6 +160,7 @@ const ProjectsProjectIdFoldersFolderIdAgentsmdRoute =
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
'/login': typeof LoginRoute
'/reset-password': typeof ResetPasswordRoute
'/signup': typeof SignupRoute
'/share/$shareId': typeof ShareShareIdRouteWithChildren
'/projects/$projectId/agentsmd': typeof ProjectsProjectIdAgentsmdRoute
@@ -177,6 +184,7 @@ export interface FileRoutesByFullPath {
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/login': typeof LoginRoute
'/reset-password': typeof ResetPasswordRoute
'/signup': typeof SignupRoute
'/projects/$projectId/agentsmd': typeof ProjectsProjectIdAgentsmdRoute
'/projects/$projectId/recently-deleted': typeof ProjectsProjectIdRecentlyDeletedRoute
@@ -200,6 +208,7 @@ export interface FileRoutesById {
__root__: typeof rootRouteImport
'/': typeof IndexRoute
'/login': typeof LoginRoute
'/reset-password': typeof ResetPasswordRoute
'/signup': typeof SignupRoute
'/share/$shareId': typeof ShareShareIdRouteWithChildren
'/projects/$projectId/agentsmd': typeof ProjectsProjectIdAgentsmdRoute
@@ -225,6 +234,7 @@ export interface FileRouteTypes {
fullPaths:
| '/'
| '/login'
| '/reset-password'
| '/signup'
| '/share/$shareId'
| '/projects/$projectId/agentsmd'
@@ -248,6 +258,7 @@ export interface FileRouteTypes {
to:
| '/'
| '/login'
| '/reset-password'
| '/signup'
| '/projects/$projectId/agentsmd'
| '/projects/$projectId/recently-deleted'
@@ -270,6 +281,7 @@ export interface FileRouteTypes {
| '__root__'
| '/'
| '/login'
| '/reset-password'
| '/signup'
| '/share/$shareId'
| '/projects/$projectId/agentsmd'
@@ -294,6 +306,7 @@ export interface FileRouteTypes {
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
LoginRoute: typeof LoginRoute
ResetPasswordRoute: typeof ResetPasswordRoute
SignupRoute: typeof SignupRoute
ShareShareIdRoute: typeof ShareShareIdRouteWithChildren
ProjectsProjectIdAgentsmdRoute: typeof ProjectsProjectIdAgentsmdRoute
@@ -321,6 +334,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SignupRouteImport
parentRoute: typeof rootRouteImport
}
'/reset-password': {
id: '/reset-password'
path: '/reset-password'
fullPath: '/reset-password'
preLoaderRoute: typeof ResetPasswordRouteImport
parentRoute: typeof rootRouteImport
}
'/login': {
id: '/login'
path: '/login'
@@ -481,6 +501,7 @@ const ShareShareIdRouteWithChildren = ShareShareIdRoute._addFileChildren(ShareSh
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
LoginRoute: LoginRoute,
ResetPasswordRoute: ResetPasswordRoute,
SignupRoute: SignupRoute,
ShareShareIdRoute: ShareShareIdRouteWithChildren,
ProjectsProjectIdAgentsmdRoute: ProjectsProjectIdAgentsmdRoute,
@@ -0,0 +1,212 @@
import { AuthLayout } from '@/ui/components/auth-layout'
import { Button } from '@/ui/components/ui/button'
import { Input } from '@/ui/components/ui/input'
import { Label } from '@/ui/components/ui/label'
import { resetPassword } from '@/ui/lib/auth-client'
import { m } from '@/ui/paraglide/messages.js'
import { zodResolver } from '@hookform/resolvers/zod'
import { createLazyFileRoute, Link, useNavigate } from '@tanstack/react-router'
import { AlertCircle, ArrowRight, CheckCircle2, KeyRound, Loader2, Lock } from 'lucide-react'
import { useEffect, useState } from 'react'
import { useForm } from 'react-hook-form'
import { z } from 'zod'
const resetPasswordFormSchema = z
.object({
password: z.string().min(3, m.password_min_length()),
confirmPassword: z.string().min(3, m.password_min_length()),
})
.refine((data) => data.password === data.confirmPassword, {
message: m.passwords_do_not_match(),
path: ['confirmPassword'],
})
type ResetPasswordFormSchema = z.infer<typeof resetPasswordFormSchema>
export const Route = createLazyFileRoute('/reset-password')({
component: ResetPasswordPage,
})
function ResetPasswordPage() {
const navigate = useNavigate()
const search = Route.useSearch()
const token = search.token || ''
const [error, setError] = useState<string | null>(null)
const [loading, setLoading] = useState(false)
const [success, setSuccess] = useState(false)
const form = useForm<ResetPasswordFormSchema>({
resolver: zodResolver(resetPasswordFormSchema),
defaultValues: {
password: '',
confirmPassword: '',
},
})
useEffect(() => {
if (success) {
const timer = setTimeout(() => {
navigate({ to: '/login' })
}, 3000)
return () => clearTimeout(timer)
}
}, [success, navigate])
const onSubmit = async (data: ResetPasswordFormSchema) => {
if (!token) {
setError(m.invalid_reset_token())
return
}
setLoading(true)
setError(null)
const { error: resetError } = await resetPassword({
newPassword: data.password,
token,
})
setLoading(false)
if (resetError) {
setError(resetError.message || m.invalid_reset_token())
return
}
setSuccess(true)
}
return (
<AuthLayout>
<div className="mb-8">
<h1 className="text-2xl font-bold tracking-tight text-foreground">{m.reset_password()}</h1>
<p className="text-muted-foreground text-sm mt-1">{m.reset_password_subtitle()}</p>
</div>
{!token ? (
<div className="space-y-6">
<div className="p-4 bg-destructive/10 border border-destructive/20 text-destructive rounded-xl text-sm flex items-start gap-3">
<AlertCircle className="w-5 h-5 shrink-0 mt-0.5" />
<div className="space-y-1">
<p className="font-semibold">{m.invalid_reset_token()}</p>
<p className="text-xs text-muted-foreground">{m.invalid_reset_token_description()}</p>
</div>
</div>
<Link to="/login" className="block w-full">
<Button
variant="outline"
className="w-full h-11 rounded-xl flex items-center justify-center gap-2"
>
{m.go_to_login()}
<ArrowRight className="w-4 h-4" />
</Button>
</Link>
</div>
) : success ? (
<div className="space-y-6">
<div className="p-4 bg-emerald-500/10 border border-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded-xl text-sm flex items-start gap-3">
<CheckCircle2 className="w-5 h-5 shrink-0 mt-0.5" />
<div className="space-y-1">
<p className="font-semibold">{m.password_reset_success()}</p>
<p className="text-xs text-muted-foreground">
{m.password_reset_success_description()}
</p>
</div>
</div>
<Link to="/login" className="block w-full">
<Button className="w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0">
{m.go_to_login()}
<ArrowRight className="w-4 h-4" />
</Button>
</Link>
</div>
) : (
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-5">
{error && (
<div className="p-3 bg-destructive/10 border border-destructive/20 text-destructive rounded-xl text-sm text-center font-medium">
{error}
</div>
)}
<div className="space-y-2">
<Label
htmlFor="password"
className="text-xs font-semibold text-muted-foreground tracking-wide uppercase"
>
{m.new_password()}
</Label>
<div className="relative group">
<Lock className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground transition-colors group-focus-within:text-rose-500" />
<Input
id="password"
type="password"
{...form.register('password')}
placeholder={m.new_password_placeholder()}
className="pl-10.5 h-11 border-border focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"
/>
</div>
{form.formState.errors.password && (
<p className="text-destructive text-xs font-medium">
{form.formState.errors.password.message}
</p>
)}
</div>
<div className="space-y-2">
<Label
htmlFor="confirmPassword"
className="text-xs font-semibold text-muted-foreground tracking-wide uppercase"
>
{m.confirm_password()}
</Label>
<div className="relative group">
<Lock className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground transition-colors group-focus-within:text-rose-500" />
<Input
id="confirmPassword"
type="password"
{...form.register('confirmPassword')}
placeholder={m.confirm_password_placeholder()}
className="pl-10.5 h-11 border-border focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"
/>
</div>
{form.formState.errors.confirmPassword && (
<p className="text-destructive text-xs font-medium">
{form.formState.errors.confirmPassword.message}
</p>
)}
</div>
<Button
type="submit"
className="w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0"
disabled={loading}
>
{loading ? (
<>
<Loader2 className="h-4 w-4 animate-spin" />
{m.resetting_password()}
</>
) : (
<>
<KeyRound className="w-4 h-4" />
{m.reset_password()}
</>
)}
</Button>
<div className="pt-2 text-center text-sm">
<Link
to="/login"
className="font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-1"
>
{m.go_to_login()}
</Link>
</div>
</form>
)}
</AuthLayout>
)
}
+18
View File
@@ -0,0 +1,18 @@
import { createFileRoute, redirect } from '@tanstack/react-router'
import { useAuthStore } from '@/ui/stores/auth'
import { z } from 'zod'
const searchSchema = z.object({
token: z.string().catch(''),
})
export const Route = createFileRoute('/reset-password')({
validateSearch: (search) => searchSchema.parse(search),
beforeLoad: () => {
if (useAuthStore.getState().user) {
throw redirect({
to: '/',
})
}
},
})