예제 #1
0
 public function changePassword(User $u)
 {
     try {
         $raw = $u->provideRawPassword();
         $hash = $this->generateNewPassword($raw);
         $user = $this->userDao->find($u->getId());
         $user->setPassword($hash);
         $user->setPasswordChangeRequired(false);
         $this->entityManager->flush();
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
     $user->insertRawPassword($raw);
     $this->onPasswordChange(clone $user);
 }
예제 #2
0
 public function notifyNewPassword(User $u)
 {
     $subjKey = "systemModule.notification.newPassword.subject";
     $bodyKey = "systemModule.notification.newPassword.body";
     $subject = $this->translator->translate($subjKey, null, ["host" => $this->getHostName()]);
     $body = $this->translator->translate($bodyKey, null, ["name" => $u->getName(), "surname" => $u->getSurname(), "pass" => $u->provideRawPassword()]);
     $mail = new Message();
     $mail->setFrom($this->getSenderEmail())->setSubject($subject)->setBody($body)->addTo($u->getContact()->getEmail());
     $this->send($mail);
 }