fix: harden struts auth responses

This commit is contained in:
Codex
2026-04-01 10:33:02 +08:00
parent 589f33dc92
commit fb18c4d99a
6 changed files with 26 additions and 12 deletions

View File

@@ -34,15 +34,15 @@ public class UserAction extends ActionSupport {
private boolean isValid() {
boolean valid = true;
if (username == null || username.length() < 3) {
addFieldError("username", "用户名至少 3 个字符。 / Username must be at least 3 characters.");
addFieldError("username", "用户名至少 3 个字符。/ Username must be at least 3 characters.");
valid = false;
}
if (email == null || !email.contains("@")) {
addFieldError("email", "请输入有效邮箱。 / Enter a valid email address.");
addFieldError("email", "请输入有效邮箱。/ Enter a valid email address.");
valid = false;
}
if (phone == null || phone.replaceAll("[^0-9]", "").length() < 7) {
addFieldError("phone", "手机号至少 7 位数字。 / Enter at least 7 digits for the phone number.");
addFieldError("phone", "手机号至少 7 位数字。/ Enter at least 7 digits for the phone number.");
valid = false;
}
return valid;