/** * Reset the password * * @param PasswordEntity $passwordEntity * @param UserInterface $user * @param array $data * @return boolean */ public function resetPassword(PasswordEntity $passwordEntity, UserInterface $user, array $data) { $newPass = $data['newCredential']; $bcrypt = new Bcrypt(); $bcrypt->setCost($this->getZfcUserOptions()->getPasswordCost()); $pass = $bcrypt->create($newPass); $user->setPassword($pass); $this->getEventManager()->trigger(__FUNCTION__, $this, ['user' => $user]); $this->getEntityManager()->remove($passwordEntity); $this->getEntityManager()->flush(); $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, ['user' => $user]); return true; }
public function transferChangesToExistingEntity(UserInterface $newEntity, UserInterface $existingEntity) { $existingEntity->setUsername($newEntity->getUsername()); $existingEntity->setEmail($newEntity->getEmail()); $existingEntity->setDisplayName($newEntity->getDisplayName()); $existingEntity->setState($newEntity->getState()); $passwordHash = $newEntity->getPassword(); if (!empty($passwordHash)) { $existingEntity->setPassword($passwordHash); } }