mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-03 06:24:30 +00:00
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:
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -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 = {};
|
||||
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 = {};
|
||||
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
|
||||
});
|
||||
+16
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 = {};
|
||||
@@ -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)
|
||||
});
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
@@ -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: '/',
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user