feat: finish bilingual session auth learning lab
This commit is contained in:
@@ -14,6 +14,7 @@ public class UserAction extends ActionSupport {
|
||||
private String phone;
|
||||
private String submittedAt;
|
||||
private String profileStage;
|
||||
private boolean profileReady;
|
||||
|
||||
public String submit() {
|
||||
username = normalize(username);
|
||||
@@ -25,22 +26,23 @@ public class UserAction extends ActionSupport {
|
||||
}
|
||||
|
||||
submittedAt = LocalDateTime.now().format(TIME_FORMATTER);
|
||||
profileStage = (phone != null && phone.length() >= 7) ? "Profile ready for follow-up demos." : "Profile captured. Add a stronger phone number next time.";
|
||||
profileReady = phone != null && phone.length() >= 7;
|
||||
profileStage = profileReady ? "ready" : "review";
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
private boolean isValid() {
|
||||
boolean valid = true;
|
||||
if (username == null || username.length() < 3) {
|
||||
addFieldError("username", "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", "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;
|
||||
@@ -81,4 +83,8 @@ public class UserAction extends ActionSupport {
|
||||
public String getProfileStage() {
|
||||
return profileStage;
|
||||
}
|
||||
|
||||
public boolean isProfileReady() {
|
||||
return profileReady;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user