File tree Expand file tree Collapse file tree
eladmin-system/src/main/java/me/zhengjie/modules/system Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package me .zhengjie .modules .system .domain .vo ;
2+
3+ import lombok .Data ;
4+
5+ /**
6+ * 修改密码的 Vo 类
7+ * @author Zheng Jie
8+ * @date 2019年7月11日13:59:49
9+ */
10+ @ Data
11+ public class UserPassVo {
12+
13+ private String oldPass ;
14+
15+ private String newPass ;
16+ }
Original file line number Diff line number Diff line change 66import me .zhengjie .domain .VerificationCode ;
77import me .zhengjie .modules .system .domain .User ;
88import me .zhengjie .exception .BadRequestException ;
9+ import me .zhengjie .modules .system .domain .vo .UserPassVo ;
910import me .zhengjie .modules .system .service .DeptService ;
1011import me .zhengjie .modules .system .service .RoleService ;
1112import me .zhengjie .modules .system .service .dto .RoleSmallDTO ;
@@ -127,15 +128,15 @@ public ResponseEntity delete(@PathVariable Long id){
127128 * @return
128129 */
129130 @ PostMapping (value = "/users/updatePass" )
130- public ResponseEntity updatePass (@ RequestBody User user ){
131+ public ResponseEntity updatePass (@ RequestBody UserPassVo user ){
131132 UserDetails userDetails = SecurityUtils .getUserDetails ();
132- if (!userDetails .getPassword ().equals (EncryptUtils .encryptPassword (user .getPassword ()))){
133+ if (!userDetails .getPassword ().equals (EncryptUtils .encryptPassword (user .getOldPass ()))){
133134 throw new BadRequestException ("修改失败,旧密码错误" );
134135 }
135- if (userDetails .getPassword ().equals (EncryptUtils .encryptPassword (user .getPassword ()))){
136+ if (userDetails .getPassword ().equals (EncryptUtils .encryptPassword (user .getNewPass ()))){
136137 throw new BadRequestException ("新密码不能与旧密码相同" );
137138 }
138- userService .updatePass (userDetails .getUsername (),EncryptUtils .encryptPassword (user .getPassword ()));
139+ userService .updatePass (userDetails .getUsername (),EncryptUtils .encryptPassword (user .getNewPass ()));
139140 return new ResponseEntity (HttpStatus .OK );
140141 }
141142
You can’t perform that action at this time.
0 commit comments