fix: 用户名唯一性竞态处理 + 密码长度上限 + JSON.parse 安全
- #6: register/user PUT 捕获 P2002 返回 409,apiHandler 全局兜底 - #8: GET /api/user 的 JSON.parse(preferences) 加 try/catch 防崩溃 - #12: 密码校验加 128 字符上限防 DoS - #29: ApiError.name 设为 "ApiError" 便于调试
This commit is contained in:
@@ -12,6 +12,9 @@ export function validatePassword(password: string, label = "密码"): void {
|
||||
if (password.length < 6) {
|
||||
throw new ApiError(`${label}至少 6 个字符`);
|
||||
}
|
||||
if (password.length > 128) {
|
||||
throw new ApiError(`${label}不能超过 128 个字符`);
|
||||
}
|
||||
}
|
||||
|
||||
export function validateEmail(email: string): void {
|
||||
|
||||
Reference in New Issue
Block a user