Commit 4fb59ba7 authored by 技术部-任文超's avatar 技术部-任文超

优化(合并冗余判断)

parent 1c137c61
......@@ -1363,7 +1363,7 @@ public class InnerController implements IBaseController {
@RequestMapping(path = "/user/password/reset", method = RequestMethod.POST)
public JsonResult resetPassword(@RequestParam("phone") String phone, @RequestParam(required = false) String password) {
if (ValidationUtil.validatePhoneNo(phone)) {
if (StringUtils.isNotBlank(password) && (password.length() < 6 || password.length() > 12)) {
if (PasswordUtil.validPwd(password)) {
return JsonResult.buildErrorStateResult("密码应为6-12位", null);
}
try {
......
......@@ -263,7 +263,7 @@ public class UserController implements IBaseController {
log.info("用户注册失败,密码不能为空:register -> registerFrom:{}, phoneNo:{}, password:{}", registerFrom, phoneNo, password);
return JsonResult.buildErrorStateResult("密码不能为空", null);
}
if (password.length() < 6 || password.length() > 12) {
if (PasswordUtil.validPwd(password)) {
log.info("用户注册失败,密码长度须在6位至12位之间:register -> registerFrom:{}, phoneNo:{}, password:{}", registerFrom, phoneNo, password);
return JsonResult.buildErrorStateResult("密码应为6-12位", null);
}
......@@ -336,7 +336,7 @@ public class UserController implements IBaseController {
if (StringUtils.isBlank(password)) {
return JsonResult.buildErrorStateResult("密码不能为空", null);
}
if (password.length() < 6 || password.length() > 12) {
if (PasswordUtil.validPwd(password)) {
return JsonResult.buildErrorStateResult("密码应为6-12位", null);
}
verifyPhoneAndCode(phoneNo, verificationCode);
......@@ -365,7 +365,7 @@ public class UserController implements IBaseController {
if (StringUtils.isBlank(passwordNew)) {
return JsonResult.buildErrorStateResult("密码不能为空", null);
}
if (passwordNew.length() < 6 || passwordNew.length() > 12) {
if (PasswordUtil.validPwd(password)) {
return JsonResult.buildErrorStateResult("密码应为6-12位", null);
}
User user = userService.findByPhoneWithCache(phoneNo);
......
......@@ -75,4 +75,14 @@ public class PasswordUtil {
return pwd.toString();
}
/**
* 校验密码是否合法
*
* @param password
* @return
*/
public static boolean validPwd(String password) {
return Objects.nonNull(password) && (password.length() < 6 || password.length() > 12);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment