密码校验
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user