Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
1d517316
Commit
1d517316
authored
Jul 11, 2019
by
Elune
Browse files
修改密码优化
parent
abb310bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/UserPassVo.java
0 → 100644
View file @
1d517316
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
;
}
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java
View file @
1d517316
...
@@ -6,6 +6,7 @@ import me.zhengjie.domain.Picture;
...
@@ -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 {
...
@@ -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
User
PassVo
user
){
UserDetails
userDetails
=
SecurityUtils
.
getUserDetails
();
UserDetails
userDetails
=
SecurityUtils
.
getUserDetails
();
if
(!
userDetails
.
getPassword
().
equals
(
EncryptUtils
.
encryptPassword
(
user
.
getPass
word
()))){
if
(!
userDetails
.
getPassword
().
equals
(
EncryptUtils
.
encryptPassword
(
user
.
get
Old
Pass
()))){
throw
new
BadRequestException
(
"修改失败,旧密码错误"
);
throw
new
BadRequestException
(
"修改失败,旧密码错误"
);
}
}
if
(
userDetails
.
getPassword
().
equals
(
EncryptUtils
.
encryptPassword
(
user
.
getPass
word
()))){
if
(
userDetails
.
getPassword
().
equals
(
EncryptUtils
.
encryptPassword
(
user
.
get
New
Pass
()))){
throw
new
BadRequestException
(
"新密码不能与旧密码相同"
);
throw
new
BadRequestException
(
"新密码不能与旧密码相同"
);
}
}
userService
.
updatePass
(
userDetails
.
getUsername
(),
EncryptUtils
.
encryptPassword
(
user
.
getPass
word
()));
userService
.
updatePass
(
userDetails
.
getUsername
(),
EncryptUtils
.
encryptPassword
(
user
.
get
New
Pass
()));
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment