修复密码强度检测BUG

v1.4.1
hiparker 4 years ago
parent f0609ef436
commit e62a655035

@ -53,6 +53,13 @@ public class UserAndOrgModel extends ApiWrapper {
@ValidationArgsLenMax(50)
private String password;
/** 登录密码强度 */
@ApiModelProperty(value = "登录密码强度")
@ExcelIgnore
@ValidationArgsLenMin(1)
@ValidationArgsLenMax(1)
private String passwordLevel;
/** 盐值,密码秘钥 */
@ApiModelProperty(value = "盐值,密码秘钥")
@ExcelIgnore

@ -53,6 +53,13 @@ public class UserModel extends ApiWrapper {
@ValidationArgsLenMax(50)
private String password;
/** 登录密码强度 */
@ApiModelProperty(value = "登录密码强度")
@ExcelIgnore
@ValidationArgsLenMin(1)
@ValidationArgsLenMax(1)
private String passwordLevel;
/** 盐值,密码秘钥 */
@ApiModelProperty(value = "盐值,密码秘钥")
@ExcelIgnore

@ -59,10 +59,17 @@ public class UserPassword implements Serializable {
@ValidationArgsLenMax(50)
private String newPassword;
/** 盐值,密码秘钥 */
@ApiModelProperty(value = "盐值,密码秘钥")
/** 盐值,密码秘钥 前端不可改*/
@ApiModelProperty(value = "盐值,密码秘钥 前端不可改")
@ExcelIgnore
@ValidationArgsLenMax(50)
private String salt;
/** 登录密码强度 前端不可改 */
@ApiModelProperty(value = "登录密码强度 前端不可改")
@ExcelIgnore
@ValidationArgsLenMin(1)
@ValidationArgsLenMax(1)
private String passwordLevel;
}

@ -261,7 +261,7 @@ public class CheckStrength {
return level;
}
/**
*
*
*
* @param passwd
* @return

@ -40,6 +40,9 @@ public class SysUser extends BaseEntity {
/** 登录密码 */
private String password;
/** 登录密码强度 */
private String passwordLevel;
/** 盐值,密码秘钥 */
private String secretKey;

@ -43,6 +43,9 @@ public class SysUserAndOrg extends BaseEntity {
/** 登录密码 */
private String password;
/** 登录密码强度 */
private String passwordLevel;
/** 盐值,密码秘钥 */
private String secretKey;

@ -8,6 +8,7 @@
a.username as username,
a.password as password,
a.password_level as passwordLevel,
a.secret_key as secretKey,
a.no as no,
a.real_name as realName,
@ -146,6 +147,7 @@
update sys_user
set
password = #{newPassword},
password_level = #{passwordLevel},
secret_key = #{salt}
where id = #{userId}
</update>

@ -33,6 +33,7 @@ import org.opsli.api.wrapper.system.user.UserPassword;
import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.enums.DictType;
import org.opsli.common.exception.ServiceException;
import org.opsli.common.utils.CheckStrength;
import org.opsli.common.utils.HumpUtil;
import org.opsli.common.utils.ListDistinctUtil;
import org.opsli.common.utils.WrapperUtil;
@ -123,6 +124,10 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
model.setSecretKey(
RandomUtil.randomString(20)
);
// 获得密码强度
model.setPasswordLevel(
CheckStrength.getPasswordLevel(model.getPassword()).getCode()
);
// 处理密码
model.setPassword(
UserUtil.handlePassword(model.getPassword(),
@ -590,6 +595,10 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
userPassword.setSalt(
RandomUtil.randomString(20)
);
// 获得密码强度
userPassword.setPasswordLevel(
CheckStrength.getPasswordLevel(userPassword.getNewPassword()).getCode()
);
// 处理密码
userPassword.setNewPassword(
UserUtil.handlePassword(userPassword.getNewPassword(),
@ -620,6 +629,10 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
userPassword.setSalt(
RandomUtil.randomString(20)
);
// 获得密码强度
userPassword.setPasswordLevel(
CheckStrength.getPasswordLevel(userPassword.getNewPassword()).getCode()
);
// 处理密码
userPassword.setNewPassword(
UserUtil.handlePassword(userPassword.getNewPassword(),

@ -119,10 +119,6 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
UserInfo userInfo = WrapperUtil.transformInstance(user, UserInfo.class);
userInfo.setRoles(userRolesByUserId);
userInfo.setPerms(userAllPermsByUserId);
// 获得密码强度
userInfo.setPasswordLevel(
CheckStrength.getPasswordLevel(user.getPassword()).getCode()
);
// 判断是否是超级管理员
if(StringUtils.equals(UserUtil.SUPER_ADMIN, user.getUsername())){

Loading…
Cancel
Save