用户密码验证加强

v1.4.1
Parker 4 years ago
parent 2b4cf0c46c
commit 9777a4b11b

@ -23,6 +23,7 @@ import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs;
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMin;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.plugins.excel.annotation.ExcelInfo;
@ -50,6 +51,7 @@ public class UserAndOrgModel extends ApiWrapper {
@ApiModelProperty(value = "登录密码")
@ExcelIgnore
// 验证器
@ValidationArgsLenMin(6)
@ValidationArgsLenMax(50)
private String password;

@ -23,6 +23,7 @@ import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs;
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMin;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.plugins.excel.annotation.ExcelInfo;
@ -50,6 +51,7 @@ public class UserModel extends ApiWrapper {
@ApiModelProperty(value = "登录密码")
@ExcelIgnore
// 验证器
@ValidationArgsLenMin(6)
@ValidationArgsLenMax(50)
private String password;

@ -22,6 +22,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import org.opsli.common.annotation.validation.ValidationArgs;
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMin;
import org.opsli.common.enums.ValiArgsType;
import java.io.Serializable;
@ -48,6 +49,7 @@ public class UserPassword implements Serializable {
@ApiModelProperty(value = "旧密码")
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
@ValidationArgsLenMin(6)
@ValidationArgsLenMax(50)
private String oldPassword;
@ -55,6 +57,7 @@ public class UserPassword implements Serializable {
@ApiModelProperty(value = "新密码")
// 验证器
@ValidationArgs({ValiArgsType.IS_NOT_NULL})
@ValidationArgsLenMin(6)
@ValidationArgsLenMax(50)
private String newPassword;

@ -51,13 +51,13 @@ public enum SystemMsg implements BaseMsg {
*/
EXCEPTION_USER_UNIQUE(20300,"该用户已存在"),
EXCEPTION_USER_PASSWORD_ERROR(20301,"旧密码不正确"),
EXCEPTION_USER_ID_NOT_NULL(20302,"用户Id不可为空"),
EXCEPTION_USER_ROLES_ERROR(20303,"用户角色设置失败"),
EXCEPTION_USER_MENU_NOT_NULL(20304,"用户暂无角色菜单,请设置后登录"),
EXCEPTION_USER_NO_UNIQUE(20305,"该工号已存在"),
EXCEPTION_ORG_NOT_NULL(20306,"组织不可为空"),
EXCEPTION_USER_ORG_ERROR(20307,"用户组织设置失败"),
EXCEPTION_USER_PASSWORD_EQ_ERROR(20302,"旧密码不可以等于新密码"),
EXCEPTION_USER_ID_NOT_NULL(20303,"用户Id不可为空"),
EXCEPTION_USER_ROLES_ERROR(20304,"用户角色设置失败"),
EXCEPTION_USER_MENU_NOT_NULL(20305,"用户暂无角色菜单,请设置后登录"),
EXCEPTION_USER_NO_UNIQUE(20306,"该工号已存在"),
EXCEPTION_ORG_NOT_NULL(20307,"组织不可为空"),
EXCEPTION_USER_ORG_ERROR(20308,"用户组织设置失败"),
/**

@ -276,6 +276,12 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
if(userModel == null){
return false;
}
// 判断老密码是否等于新密码
if(userPassword.getOldPassword().equals(userPassword.getNewPassword())){
throw new ServiceException(SystemMsg.EXCEPTION_USER_PASSWORD_EQ_ERROR);
}
// 获得 处理后 老密码
String orlPassword = UserUtil.handlePassword(userPassword.getOldPassword(),
userModel.getSecretkey());

Loading…
Cancel
Save