// We have to find the user because if we use em.merge(user)
// user.plainPassword will be deleted (because it is transient).
IdpUser foundUser = em.find(IdpUser.class, user.getId());
if (foundUser == null) {
log.error("Error resetting password. User not found {}.", user.getUsername());
throw new UserNotFoundException("Error resetting password. User not found " + user.getUsername());
}
foundUser.setPlainPassword(user.getPlainPassword());
foundUser.setActionToken("");
foundUser.setStatus(IdpUserState.ACTIVE);
em.persist(foundUser);