This commit is contained in:
fit2-zhao 2020-09-30 17:10:35 +08:00
commit fd09d77563
1 changed files with 13 additions and 15 deletions

View File

@ -487,20 +487,18 @@ public class UserService {
/*修改当前用户用户密码*/
private User updateCurrentUserPwd(EditPassWordRequest request) {
if (SessionUtils.getUser() != null) {
User user = userMapper.selectByPrimaryKey(SessionUtils.getUser().getId());
String pwd = user.getPassword();
String prepwd = CodingUtil.md5(request.getPassword(), "utf-8");
String newped = request.getNewpassword();
if (StringUtils.isNotBlank(prepwd)) {
if (prepwd.trim().equals(pwd.trim())) {
user.setPassword(CodingUtil.md5(newped));
String oldPassword = CodingUtil.md5(request.getPassword(), "utf-8");
String newPassword = request.getNewpassword();
UserExample userExample = new UserExample();
userExample.createCriteria().andIdEqualTo(SessionUtils.getUser().getId()).andPasswordEqualTo(oldPassword);
List<User> users = userMapper.selectByExample(userExample);
if (!CollectionUtils.isEmpty(users)) {
User user = users.get(0);
user.setPassword(CodingUtil.md5(newPassword));
user.setUpdateTime(System.currentTimeMillis());
return user;
}
}
MSException.throwException(Translator.get("password_modification_failed"));
}
return null;
}
@ -512,8 +510,8 @@ public class UserService {
/*管理员修改用户密码*/
private User updateUserPwd(EditPassWordRequest request) {
User user = userMapper.selectByPrimaryKey(request.getId());
String newped = request.getNewpassword();
user.setPassword(CodingUtil.md5(newped));
String newPassword = request.getNewpassword();
user.setPassword(CodingUtil.md5(newPassword));
user.setUpdateTime(System.currentTimeMillis());
return user;
}