Explorar o código

个人中心-修改密码

sqg %!s(int64=3) %!d(string=hai) anos
pai
achega
959aab7d50

+ 9 - 0
tianhu-system/src/main/java/com/tianhu/system/controller/SysProfileController.java

@@ -22,6 +22,8 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * 个人信息 业务处理
@@ -92,6 +94,13 @@ public class SysProfileController extends BaseController
         {
             return AjaxResult.error("修改密码失败,旧密码错误");
         }
+        String chackPassword = "^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$).{6,20}$";
+        Pattern regePassword = Pattern.compile(chackPassword);
+        Matcher matcherPassword = regePassword.matcher(newPassword);
+        boolean isMatPassword = matcherPassword.matches();
+        if(!isMatPassword){
+            return AjaxResult.error(500,"密码请包含数字,英文,字符中的两种以上,长度6-20位");
+        }
         if (SecurityUtils.matchesPassword(newPassword, password))
         {
             return AjaxResult.error("新密码不能与旧密码相同");