@Test public void changeUserPassword() { ChangePasswordDTO dto = new ChangePasswordDTO(); dto.setNewPassword("147258"); dto.setConfirmPassword("147258"); dto.setOldPassword("123456"); UserDO user = userService.changeUserPassword(dto); boolean b = userIdentityService.verifyUsernamePassword(user.getId(), "pedro", "147258"); assertTrue(b); }
@Override public UserDO changeUserPassword(ChangePasswordDTO dto) { UserDO user = LocalUser.getLocalUser(); boolean valid = userIdentityService.verifyUsernamePassword(user.getId(), user.getUsername(), dto.getOldPassword()); if (!valid) { throw new ParameterException("password invalid, please enter correct password", 10032); } valid = userIdentityService.changePassword(user.getId(), dto.getNewPassword()); if (!valid) { throw new FailedException("password change failed", 10011); } return user; }
UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements UserService { @Override public UserDO changeUserPassword(ChangePasswordDTO dto) { UserDO user = LocalUser.getLocalUser(); boolean valid = userIdentityService.verifyUsernamePassword(user.getId(), user.getUsername(), dto.getOldPassword()); if (!valid) { throw new ParameterException("password invalid, please enter correct password", 10032); } valid = userIdentityService.changePassword(user.getId(), dto.getNewPassword()); if (!valid) { throw new FailedException("password change failed", 10011); } return user; } }
UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements UserService { @Override public UserDO changeUserPassword(ChangePasswordDTO dto) { UserDO user = LocalUser.getLocalUser(); boolean valid = userIdentityService.verifyUsernamePassword(user.getId(), user.getUsername(), dto.getOldPassword()); if (!valid) { throw new ParameterException("password invalid, please enter correct password", 10032); } valid = userIdentityService.changePassword(user.getId(), dto.getNewPassword()); if (!valid) { throw new FailedException("password change failed", 10011); } return user; }  }
UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements UserService { @Override public UserDO changeUserPassword(ChangePasswordDTO dto) { UserDO user = LocalUser.getLocalUser(); boolean valid = userIdentityService.verifyUsernamePassword(user.getId(), user.getUsername(), dto.getOldPassword()); if (!valid) { throw new ParameterException("password invalid, please enter correct password", 10032); } valid = userIdentityService.changePassword(user.getId(), dto.getNewPassword()); if (!valid) { throw new FailedException("password change failed", 10011); } return user; }  @Transactional @Override UserDO createUser(RegisterDTO dto); @Transactional @Override UserDO updateUserInfo(UpdateInfoDTO dto); @Override UserDO changeUserPassword(ChangePasswordDTO dto); @Override List<GroupDO> getUserGroups(Long userId); @Override List<Map<String, List<Map<String, String>>>> getStructualUserPermissions(Long userId); @Override List<PermissionDO> getUserPermissions(Long userId); @Override UserDO getUserByUsername(String username); @Override boolean checkUserExistByUsername(String username); @Override boolean checkUserExistByEmail(String email); @Override boolean checkUserExistById(Long id); @Override IPage<UserDO> getUserPageByGroupId(Page pager, Long groupId); }
UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements UserService { @Override public UserDO changeUserPassword(ChangePasswordDTO dto) { UserDO user = LocalUser.getLocalUser(); boolean valid = userIdentityService.verifyUsernamePassword(user.getId(), user.getUsername(), dto.getOldPassword()); if (!valid) { throw new ParameterException("password invalid, please enter correct password", 10032); } valid = userIdentityService.changePassword(user.getId(), dto.getNewPassword()); if (!valid) { throw new FailedException("password change failed", 10011); } return user; }  @Transactional @Override UserDO createUser(RegisterDTO dto); @Transactional @Override UserDO updateUserInfo(UpdateInfoDTO dto); @Override UserDO changeUserPassword(ChangePasswordDTO dto); @Override List<GroupDO> getUserGroups(Long userId); @Override List<Map<String, List<Map<String, String>>>> getStructualUserPermissions(Long userId); @Override List<PermissionDO> getUserPermissions(Long userId); @Override UserDO getUserByUsername(String username); @Override boolean checkUserExistByUsername(String username); @Override boolean checkUserExistByEmail(String email); @Override boolean checkUserExistById(Long id); @Override IPage<UserDO> getUserPageByGroupId(Page pager, Long groupId);  }