Files
mnote/wolai-frontend/convex/auth.ts
T
lix-2026 cfc3af8984 fix: 恢复本地 Convex Auth 链路
- 修复 desktop 脚本在 Linux 下优先使用后端虚拟环境可执行文件
- 移除 Convex Auth 的本地密钥兜底,回到真实 deployment env
- 首页未登录时先跳转 /auth,避免根路由直接触发 workspace 初始化失败
2026-04-17 23:33:24 +08:00

33 lines
1009 B
TypeScript

import { Password } from "@convex-dev/auth/providers/Password";
import { convexAuth } from "@convex-dev/auth/server";
/**
* Convex Auth 配置
*
* 配置密码认证方式,支持用户通过邮箱和密码注册/登录。
*/
export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
providers: [
Password({
/**
* 密码要求验证
*/
validatePasswordRequirements: (password: string) => {
if (password.length < 8) {
throw new Error("密码至少需要 8 个字符");
}
},
/**
* 用户资料配置
*/
profile(params, _ctx) {
const email = typeof params.email === "string" ? params.email : String(params.email ?? "");
const name = typeof params.name === "string" ? params.name : "";
// 说明:Convex 的 Value 类型不允许 undefined;这里统一给 name 一个字符串占位。
return { email, name: name.trim() ? name : "" };
},
}),
],
});