密码校验

This commit is contained in:
lyf
2023-02-14 15:42:37 +08:00
parent adb2b2364c
commit e45a0573ca
2 changed files with 16 additions and 5 deletions

View File

@@ -93,7 +93,10 @@ public class UserInfoController {
@ApiImplicitParams({
@ApiImplicitParam(name = "UserInfo", value = "待添加的UserInfo实例", paramType = "body", dataType = "UserInfo", required = true)})
public Result<Object> add(@RequestBody UserInfo userInfo) {
userInfo.getPassword();
String s = StringUtil.passwordCheck(userInfo.getPassword());
if (s == null){
return ResultGenerator.genFailResult("密码不合规");
}
userInfoNewService.register(userInfo);
return ResultGenerator.genSuccessResult();
}
@@ -139,6 +142,10 @@ public class UserInfoController {
@ApiImplicitParams({
@ApiImplicitParam(name = "UserInfo", value = "更新的UserInfo实例", paramType = "body", dataType = "UserInfo", required = true),})
public Result<Object> forgetPassword(@RequestBody UserInfo userInfo) {
String s = StringUtil.passwordCheck(userInfo.getPassword());
if (s == null){
return ResultGenerator.genFailResult("密码不合规");
}
userInfoNewService.forgetPwd(userInfo);
return ResultGenerator.genSuccessResult();
}

View File

@@ -383,8 +383,12 @@ public class StringUtil extends StringUtils {
* @param password
* @return
*/
// public static String passwordCheck(String password){
// int length = password.length();
// if (length)
// }
public static String passwordCheck(String password){
int length = password.length();
if (length >= 7 && length <= 16){
return password;
}else {
return null;
}
}
}