fix: 取消密码长度规则,仅保留必填
This commit is contained in:
@@ -129,7 +129,7 @@ export function adminSessionRoutes() {
|
|||||||
const password = typeof body?.password === "string" ? body.password : "";
|
const password = typeof body?.password === "string" ? body.password : "";
|
||||||
const fields: Record<string, string> = {};
|
const fields: Record<string, string> = {};
|
||||||
if (!username) fields.username = "请填写用户名";
|
if (!username) fields.username = "请填写用户名";
|
||||||
if (password.length < 8) fields.password = "密码至少 8 位";
|
if (!password) fields.password = "请填写密码";
|
||||||
if (Object.keys(fields).length > 0) {
|
if (Object.keys(fields).length > 0) {
|
||||||
return jsonError(c, 422, ERR.validation_failed(fields));
|
return jsonError(c, 422, ERR.validation_failed(fields));
|
||||||
}
|
}
|
||||||
@@ -274,11 +274,11 @@ export function adminSessionRoutes() {
|
|||||||
const body = await c.req.json().catch(() => null);
|
const body = await c.req.json().catch(() => null);
|
||||||
const old_password = String(body?.old_password ?? "");
|
const old_password = String(body?.old_password ?? "");
|
||||||
const new_password = String(body?.new_password ?? "");
|
const new_password = String(body?.new_password ?? "");
|
||||||
if (new_password.length < 8) {
|
if (!new_password) {
|
||||||
return jsonError(
|
return jsonError(
|
||||||
c,
|
c,
|
||||||
422,
|
422,
|
||||||
ERR.validation_failed({ new_password: "密码至少 8 位" }),
|
ERR.validation_failed({ new_password: "请填写新密码" }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const repos = c.get("repos");
|
const repos = c.get("repos");
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const successMsg = ref("");
|
|||||||
const canSubmit = computed(
|
const canSubmit = computed(
|
||||||
() =>
|
() =>
|
||||||
form.old_password.length > 0 &&
|
form.old_password.length > 0 &&
|
||||||
form.new_password.length >= 8 &&
|
form.new_password.length > 0 &&
|
||||||
form.confirm_password.length > 0,
|
form.confirm_password.length > 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -33,10 +33,6 @@ async function onSubmit() {
|
|||||||
formError.value = "";
|
formError.value = "";
|
||||||
successMsg.value = "";
|
successMsg.value = "";
|
||||||
|
|
||||||
if (form.new_password.length < 8) {
|
|
||||||
fieldError.value.new_password = "新密码至少 8 位";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (form.new_password !== form.confirm_password) {
|
if (form.new_password !== form.confirm_password) {
|
||||||
formError.value = "两次输入的新密码不一致";
|
formError.value = "两次输入的新密码不一致";
|
||||||
return;
|
return;
|
||||||
@@ -85,7 +81,7 @@ async function onSubmit() {
|
|||||||
label="新密码"
|
label="新密码"
|
||||||
required
|
required
|
||||||
:validate-status="fieldError.new_password ? 'error' : undefined"
|
:validate-status="fieldError.new_password ? 'error' : undefined"
|
||||||
:help="fieldError.new_password || '至少 8 位'"
|
:help="fieldError.new_password"
|
||||||
>
|
>
|
||||||
<a-input-password
|
<a-input-password
|
||||||
v-model:value="form.new_password"
|
v-model:value="form.new_password"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export const usernameBody = z.object({ username: z.string() });
|
|||||||
|
|
||||||
export const setupBody = z.object({
|
export const setupBody = z.object({
|
||||||
username: z.string().min(1).max(64),
|
username: z.string().min(1).max(64),
|
||||||
password: z.string().min(8).max(128),
|
password: z.string().min(1).max(128),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const loginBody = z.object({
|
export const loginBody = z.object({
|
||||||
@@ -30,7 +30,7 @@ export const loginBody = z.object({
|
|||||||
|
|
||||||
export const changePasswordBody = z.object({
|
export const changePasswordBody = z.object({
|
||||||
old_password: z.string().min(1),
|
old_password: z.string().min(1),
|
||||||
new_password: z.string().min(8).max(128),
|
new_password: z.string().min(1).max(128),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const timeRangeQuery = z.object({
|
export const timeRangeQuery = z.object({
|
||||||
|
|||||||
Reference in New Issue
Block a user