Skip to content

Commit 8114d77

Browse files
authored
Add verification: the user can set a password with a length of less than 6 digits when updating the password, but the password length must be greater than or equal to 6 digits when logging in to canal admin, so the length verification function when updating the login password is added (#4103)
1 parent 571e7f4 commit 8114d77

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

admin/admin-web/src/main/java/com/alibaba/otter/canal/admin/service/impl/UserServiceImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class UserServiceImpl implements UserService {
2121

2222
private static byte[] seeds = "canal is best!".getBytes();
2323

24+
private static final Integer PASSWORD_LENGTH = 6;
25+
2426
public User find4Login(String username, String password) {
2527
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
2628
return null;
@@ -43,6 +45,9 @@ public User find4Login(String username, String password) {
4345
}
4446

4547
public void update(User user) {
48+
if (user.getPassword().length() < PASSWORD_LENGTH) {
49+
throw new ServiceException("The new password is too short,must more than 6 digits");
50+
}
4651
User userTmp = User.find.query().where().eq("username", user.getUsername()).findOne();
4752
if (userTmp == null) {
4853
throw new ServiceException();

0 commit comments

Comments
 (0)