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