feat: add admin user management and disable public registration

This commit is contained in:
陈煜 committed 2026-10-05 14:08:39 +08:00
1 parent cfbba73791
commit 312a5ccb86
32 files changed
+1120 -69

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
import { z } from 'zod';
import { credentials } from './validation';
export const roles = z.enum(['admin', 'user', 'readonly']);
export const loginInput = credentials.extend({
password: z
.string()
.min(1)
.max(72)
.refine((s) => Buffer.byteLength(s, 'utf8') <= 72, '密码最多 72 字节'),
});
export const adminCreateInput = credentials.extend({ role: roles.default('user') }).strict();
export const adminUpdateInput = z
.object({ role: roles.optional(), banned: z.boolean().optional() })
.strict()
.refine((v) => v.role !== undefined || v.banned !== undefined, '请选择权限或封禁状态');