|
|
|
@ -42,6 +42,8 @@ import java.util.Collections; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
import static com.cjy.traceability.framework.common.pojo.CommonResult.error; |
|
|
|
|
import static com.cjy.traceability.framework.common.pojo.CommonResult.success; |
|
|
|
@ -230,6 +232,7 @@ public class AuthController { |
|
|
|
|
if(!verification.equals(reqVO.getCaptchaVerification())){ |
|
|
|
|
return error(505,"验证码错误,请检查!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//修改密码
|
|
|
|
|
AdminUserDO user = userService.getUserByUsername(reqVO.getUsername()); |
|
|
|
|
if (user.getStatus().equals(CommonStatusEnum.DISABLE)) { |
|
|
|
@ -237,10 +240,26 @@ public class AuthController { |
|
|
|
|
return error(errorCode); |
|
|
|
|
} |
|
|
|
|
String plainText = CryptoUtils.decryptByRSA(CryptoUtils.PRIVATE_KEY, reqVO.getPassword()); |
|
|
|
|
//验证密码位数及格式
|
|
|
|
|
if(plainText.length() <=8 || plainText.length()>16){ |
|
|
|
|
return error(505,"密码长度为8-16位"); |
|
|
|
|
} |
|
|
|
|
boolean isOk = isValidPassword(plainText); |
|
|
|
|
if(!isOk){ |
|
|
|
|
return error(505,"新密码必须包含英文大小写、数字和特殊符号,请修正"); |
|
|
|
|
} |
|
|
|
|
userService.updateUserPassword(user.getId(),plainText); |
|
|
|
|
|
|
|
|
|
//密码重置完成废弃验证码
|
|
|
|
|
stringRedisTemplate.delete(reqVO.getCaptchaVerification()); |
|
|
|
|
return success("重置成功"); |
|
|
|
|
} |
|
|
|
|
public static boolean isValidPassword(String password) { |
|
|
|
|
// 正则表达式,要求至少包含一个小写字母、一个大写字母、一个数字和一个特殊符号
|
|
|
|
|
String regex = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$"; |
|
|
|
|
Pattern pattern = Pattern.compile(regex); |
|
|
|
|
Matcher matcher = pattern.matcher(password); |
|
|
|
|
return matcher.matches(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|