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