mirror of https://github.com/elunez/eladmin
修改密码优化
parent
abb310bfda
commit
1d517316ea
|
@ -0,0 +1,16 @@
|
||||||
|
package me.zhengjie.modules.system.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改密码的 Vo 类
|
||||||
|
* @author Zheng Jie
|
||||||
|
* @date 2019年7月11日13:59:49
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserPassVo {
|
||||||
|
|
||||||
|
private String oldPass;
|
||||||
|
|
||||||
|
private String newPass;
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import me.zhengjie.domain.Picture;
|
||||||
import me.zhengjie.domain.VerificationCode;
|
import me.zhengjie.domain.VerificationCode;
|
||||||
import me.zhengjie.modules.system.domain.User;
|
import me.zhengjie.modules.system.domain.User;
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
|
import me.zhengjie.modules.system.domain.vo.UserPassVo;
|
||||||
import me.zhengjie.modules.system.service.DeptService;
|
import me.zhengjie.modules.system.service.DeptService;
|
||||||
import me.zhengjie.modules.system.service.RoleService;
|
import me.zhengjie.modules.system.service.RoleService;
|
||||||
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
|
||||||
|
@ -127,15 +128,15 @@ public class UserController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/users/updatePass")
|
@PostMapping(value = "/users/updatePass")
|
||||||
public ResponseEntity updatePass(@RequestBody User user){
|
public ResponseEntity updatePass(@RequestBody UserPassVo user){
|
||||||
UserDetails userDetails = SecurityUtils.getUserDetails();
|
UserDetails userDetails = SecurityUtils.getUserDetails();
|
||||||
if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
|
if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getOldPass()))){
|
||||||
throw new BadRequestException("修改失败,旧密码错误");
|
throw new BadRequestException("修改失败,旧密码错误");
|
||||||
}
|
}
|
||||||
if(userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
|
if(userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getNewPass()))){
|
||||||
throw new BadRequestException("新密码不能与旧密码相同");
|
throw new BadRequestException("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
userService.updatePass(userDetails.getUsername(),EncryptUtils.encryptPassword(user.getPassword()));
|
userService.updatePass(userDetails.getUsername(),EncryptUtils.encryptPassword(user.getNewPass()));
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue