}
@Transactional
public ExternalUser saveUser(String userId, UpdateUserRequest request) {
validate(request);
User user = ensureUserIsLoaded(userId);
if(request.getFirstName() != null) {
user.setFirstName(request.getFirstName());
}
if(request.getLastName() != null) {
user.setLastName(request.getLastName());
}
if(request.getEmailAddress() != null) {
if(!request.getEmailAddress().equals(user.getEmailAddress())) {
user.setEmailAddress(request.getEmailAddress());
user.setVerified(false);
}
}
userRepository.save(user);
return new ExternalUser(user);
}