grs
yjxx 3 weeks ago
parent 53aa97a461
commit 31ba23d47f

@ -7,18 +7,19 @@ import lombok.Data;
@Data
public class UserModifyPasswordDTO {
@NotBlank(message = "旧密码不能为空")
@Pattern(regexp = "^.+$")
@Pattern(regexp = "^.+$", message = "旧密码不能为空")
private String oldPassword;
@NotBlank(message = "新密码不能为空")
@Pattern(regexp = "^.+$")
@Pattern(regexp = "^.+$", message = "新密码不能为空")
private String newPassword;
@NotBlank(message = "再次输入的密码不能为空")
@Pattern(regexp = "^.+$")
@Pattern(regexp = "^.+$", message = "再次输入的密码不能为空")
private String reNewPassword;
@NotBlank(message = "身份证不能为空")
@Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\\d{3}(\\d|X|x)$")
@Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\\d{3}(\\d|X|x)$",
message = "身份证格式不正确")
private String identity;
}

@ -68,7 +68,7 @@ public class CommonController {
return new Result<>(401, "账号或者密码错误", "");
}
User user = optionalUser.get();
if(!Objects.equals(userLoginByAccountDTO.getMark(), user.getMark())) {
if (!Objects.equals(userLoginByAccountDTO.getMark(), user.getMark())) {
return new Result<>(401, "请选择正确身份", "");
}
if (user.getDisabled() == 1) {
@ -125,8 +125,8 @@ public class CommonController {
// 修改个人密码
@PutMapping("/rePassword")
public Result<String> modifyPassword(@RequestHeader("Authorization") String token,
@RequestBody @Validated @NotNull UserModifyPasswordDTO userModifyPasswordDTO) {
public Result<String> modifyPassword(
@RequestBody @Validated @NotNull UserModifyPasswordDTO userModifyPasswordDTO) {
// 判断密码
if (userModifyPasswordDTO.getOldPassword().equals(userModifyPasswordDTO.getNewPassword())) {
return new Result<>(409, "新密码不得和旧密码一致", "");
@ -142,8 +142,6 @@ public class CommonController {
user.setPassword(Md5Util.getMD5String(userModifyPasswordDTO.getNewPassword()));
user.setUpdateTime(null);
userService.updateById(user);
// 删除redis当中的token
stringRedisTemplate.delete(token);
// 删除当前线程的存储信息
ThreadLocalUtil.remove();
return new Result<>(200, "密码修改成功, 请重新登陆", "");

Loading…
Cancel
Save