Skip to content

Commit 829ae5c

Browse files
committed
注册不能有符号
1 parent e8227f2 commit 829ae5c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/com/danbai/ys/service/impl/UserServiceImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121
import java.util.UUID;
2222
import java.util.concurrent.TimeUnit;
23+
import java.util.regex.Pattern;
2324

2425
/**
2526
* @author danbai
@@ -100,6 +101,11 @@ public void reg(User user, Model model, String yzm) {
100101
model.addAttribute("message", "验证码有误");
101102
return;
102103
}
104+
105+
if(!Pattern.matches("^[\u4e00-\u9fa5_a-zA-Z0-9]+$",user.getUsername())){
106+
model.addAttribute("message", "用户名不能有符号");
107+
return;
108+
}
103109
String str = registerValidateService.getVerificationCode(user.getEmail());
104110
if (str != null && str.equals(yzm)) {
105111
registerValidateService.deleteVerificationCode(user.getEmail());

0 commit comments

Comments
 (0)