Compare commits
3 Commits
c4da5decd4
...
abc03976f6
| Author | SHA1 | Date |
|---|---|---|
|
|
abc03976f6 | |
|
|
ebc5485102 | |
|
|
38ce347a06 |
|
|
@ -395,16 +395,9 @@ public class UserUpdateExe {
|
|||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updatePasswordFromApp(AppUserUpdatePassWordCmd cmd) {
|
||||
//新密码和旧密码不能相同
|
||||
if (cmd.getPassword().equals(cmd.getNewPassword())) {
|
||||
throw new BizException("新密码不能与旧密码相同");
|
||||
}
|
||||
UserE userE = new UserE();
|
||||
userE.checkPassword(cmd.getNewPassword(), cmd.getConfirmPassword());
|
||||
|
||||
BeanUtils.copyProperties(cmd, userE);
|
||||
userE.encryptionPassword();
|
||||
userGateway.updatePassword(userE);
|
||||
UserUpdatePassWordCmd userUpdatePassWordCmd = new UserUpdatePassWordCmd();
|
||||
BeanUtils.copyProperties(cmd, userUpdatePassWordCmd);
|
||||
executeUpdatePassword(userUpdatePassWordCmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -422,6 +415,10 @@ public class UserUpdateExe {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public Response executeUpdatePassword(UserUpdatePassWordCmd userUpdatePassWordCmd) {
|
||||
UserE userE = new UserE();
|
||||
if (userUpdatePassWordCmd.getPassword().equals(userUpdatePassWordCmd.getNewPassword())) {
|
||||
throw new BizException("新密码不能与旧密码相同");
|
||||
}
|
||||
userE.checkPassword(userUpdatePassWordCmd.getNewPassword(), userUpdatePassWordCmd.getConfirmPassword());
|
||||
BeanUtils.copyProperties(userUpdatePassWordCmd, userE);
|
||||
userE.encryptionPassword();
|
||||
return userGateway.updatePassword(userE);
|
||||
|
|
|
|||
|
|
@ -30,5 +30,8 @@ public class UserUpdatePassWordCmd extends Command {
|
|||
@ApiModelProperty(value = "新密码", name = "newPassword")
|
||||
@NotEmpty(message = "新密码不能为空")
|
||||
private String newPassword;
|
||||
@ApiModelProperty(value = "确认密码", name = "confirmPassword")
|
||||
@NotEmpty(message = "确认密码不能为空")
|
||||
private String confirmPassword;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
@Getter
|
||||
public enum CorpTypeEnum {
|
||||
// TODO 若修改默认密码通知前端同步修改
|
||||
OrdinaryEnterprises(0,"普通企业",UserTypeEnum.QY.getCode(), "Bb@12345678"),
|
||||
groupUnits(1, "集团单位",UserTypeEnum.QY.getCode(), "Bb@12345678"),
|
||||
share(2,"股份单位",UserTypeEnum.JG.getCode(), "Aa@12345678"),
|
||||
|
|
|
|||
|
|
@ -454,15 +454,11 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
|||
|
||||
@Override
|
||||
public void changePassword(Long id, String password) {
|
||||
//修改这个手机号下所有密码
|
||||
UserDO userDO = getById(id);
|
||||
if (userDO == null) {
|
||||
return;
|
||||
}
|
||||
String phone = userDO.getPhone();
|
||||
|
||||
List<UserDO> userDOList = getListByPhone(phone, null);
|
||||
for (UserDO userDO1 : userDOList) {
|
||||
for (UserDO userDO1 : listUsersForPasswordUpdate(userDO)) {
|
||||
userChangePassword(userDO1.getId(), password);
|
||||
}
|
||||
}
|
||||
|
|
@ -543,50 +539,58 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
|||
@Override
|
||||
public Response updatePassword(UserDO userDO) {
|
||||
UserDO oldUserDO = getById(userDO.getId());
|
||||
// TODO 验证老密码是否正确
|
||||
if (userDO.getPassword() != null && !userDO.getPassword().equals("")) {
|
||||
SingleResponse<UserDetailCO> detail = null;
|
||||
try {
|
||||
log.info("updateXgf,GBS获取用户信息{}", userDO.getId());
|
||||
detail = userFacade.getDetail(userDO.getId());
|
||||
log.info("updateXgf,GBS获取用户信息返回: {}", JSONUtil.toJsonStr(detail));
|
||||
} catch (Exception e) {
|
||||
log.error("updateXgf,GBS获取用户信息失败: {}", e.getMessage());
|
||||
}
|
||||
if (detail.getData() != null) {
|
||||
AccountPasswordCheckCmd accountPasswordCheckCmd = new AccountPasswordCheckCmd();
|
||||
accountPasswordCheckCmd.setUserId(userDO.getId());
|
||||
accountPasswordCheckCmd.setPassword(userDO.getPassword());
|
||||
log.info("updateXgf,GBS验证用户密码请求:{}", JSONUtil.toJsonStr(accountPasswordCheckCmd));
|
||||
SingleResponse<Long> response = accountFacade.checkPassword(accountPasswordCheckCmd);
|
||||
log.info("updateXgf,GBS验证用户密码返回:{}", JSONUtil.toJsonStr(response));
|
||||
if (!response.isSuccess()) {
|
||||
throw new BizException("原密码不正确");
|
||||
}
|
||||
} else {
|
||||
//验证本地密码
|
||||
UserE userE = new UserE();
|
||||
Boolean checkUserPassword = userE.checkUserEncryptionPassword(userDO.getPassword(), oldUserDO.getPassword());
|
||||
log.info("updateXgf,验证用户本地密码结果:{}", checkUserPassword);
|
||||
if (!checkUserPassword) {
|
||||
throw new BizException("密码错误");
|
||||
}
|
||||
if (userDO.getPassword() == null || userDO.getPassword().isEmpty()) {
|
||||
throw new BizException("原密码不能为空");
|
||||
}
|
||||
SingleResponse<UserDetailCO> detail = null;
|
||||
try {
|
||||
log.info("updateXgf,GBS获取用户信息{}", userDO.getId());
|
||||
detail = userFacade.getDetail(userDO.getId());
|
||||
log.info("updateXgf,GBS获取用户信息返回: {}", JSONUtil.toJsonStr(detail));
|
||||
} catch (Exception e) {
|
||||
log.error("updateXgf,GBS获取用户信息失败: {}", e.getMessage());
|
||||
}
|
||||
if (detail.getData() != null) {
|
||||
AccountPasswordCheckCmd accountPasswordCheckCmd = new AccountPasswordCheckCmd();
|
||||
accountPasswordCheckCmd.setUserId(userDO.getId());
|
||||
accountPasswordCheckCmd.setPassword(userDO.getPassword());
|
||||
log.info("updateXgf,GBS验证用户密码请求:{}", JSONUtil.toJsonStr(accountPasswordCheckCmd));
|
||||
SingleResponse<Long> response = accountFacade.checkPassword(accountPasswordCheckCmd);
|
||||
log.info("updateXgf,GBS验证用户密码返回:{}", JSONUtil.toJsonStr(response));
|
||||
if (!response.isSuccess()) {
|
||||
throw new BizException("原密码不正确");
|
||||
}
|
||||
} else {
|
||||
log.info("updateXgf,密码为空,不进行密码验证");
|
||||
//验证本地密码
|
||||
UserE userE = new UserE();
|
||||
Boolean checkUserPassword = userE.checkUserEncryptionPassword(userDO.getPassword(), oldUserDO.getPassword());
|
||||
log.info("updateXgf,验证用户本地密码结果:{}", checkUserPassword);
|
||||
if (!checkUserPassword) {
|
||||
throw new BizException("密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
//修改多个密码
|
||||
String phone = oldUserDO.getPhone();
|
||||
|
||||
List<UserDO> userDOList = getListByPhone(phone, null);
|
||||
for (UserDO userDO1 : userDOList) {
|
||||
// 有手机号则同步修改同手机号账号,无手机号则只改当前账号
|
||||
for (UserDO userDO1 : listUsersForPasswordUpdate(oldUserDO)) {
|
||||
userChangePassword(userDO1.getId(), userDO.getNewPassword());
|
||||
}
|
||||
return Response.buildSuccess();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需要同步更新密码的用户列表。主账号等无手机号场景仅更新当前用户。
|
||||
*/
|
||||
private List<UserDO> listUsersForPasswordUpdate(UserDO userDO) {
|
||||
if (StringUtils.hasText(userDO.getPhone())) {
|
||||
List<UserDO> userDOList = getListByPhone(userDO.getPhone(), null);
|
||||
if (CollUtil.isNotEmpty(userDOList)) {
|
||||
return userDOList;
|
||||
}
|
||||
}
|
||||
return Collections.singletonList(userDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateFaceUrl(UserDO userDO) {
|
||||
return updateById(userDO);
|
||||
|
|
|
|||
Loading…
Reference in New Issue