用户 修改密码
This commit is contained in:
@@ -156,11 +156,11 @@ public class UserController {
|
|||||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
UserDto user = userService.findByName(currentUsername);
|
UserDto user = userService.findByName(currentUsername);
|
||||||
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, passVo.getOldPass());
|
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, passVo.getOldPass());
|
||||||
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, passVo.getNewPass());
|
|
||||||
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
||||||
throw new BadRequestException("修改失败,旧密码错误");
|
throw new BadRequestException("修改失败,旧密码错误");
|
||||||
}
|
}
|
||||||
if (passwordEncoder.matches(newPass, user.getPassword())) {
|
System.out.println(oldPass);
|
||||||
|
if (passwordEncoder.matches(passVo.getNewPass(), user.getPassword())) {
|
||||||
throw new BadRequestException("新密码不能与旧密码相同");
|
throw new BadRequestException("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
String encPass = MD5Utils.encrypt( passVo.getNewPass());
|
String encPass = MD5Utils.encrypt( passVo.getNewPass());
|
||||||
@@ -170,7 +170,7 @@ public class UserController {
|
|||||||
}else {
|
}else {
|
||||||
shopStaffRepository.updatePass(currentUsername,encPass,System.currentTimeMillis());
|
shopStaffRepository.updatePass(currentUsername,encPass,System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
userService.updatePass(user.getUsername(),passwordEncoder.encode(newPass));
|
userService.updatePass(user.getUsername(),passwordEncoder.encode(passVo.getNewPass()));
|
||||||
onlineUserService.logout(tokenProvider.getToken(request));
|
onlineUserService.logout(tokenProvider.getToken(request));
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user