/**
  * @param Invitation $invitation
  * @throws InvitationExpiredException
  * @throws SendException
  */
 public function sendInvitation(Invitation $invitation)
 {
     try {
         $this->emailNotifier->send('Výčetkový systém <' . $this->systemEmail . '>', $invitation->email, function (ITemplate $template, Invitation $invitation, $senderName, $applicationUrl) {
             $template->setFile(__DIR__ . '/../../model/Notifications/templates/invitation.latte');
             $template->invitation = $invitation;
             $template->username = $senderName;
             $template->applicationUrl = $applicationUrl;
         }, [$invitation, $invitation->getSender()->username, $this->applicationUrl]);
     } catch (SendException $e) {
         $this->onCritical(sprintf('Invitation sending failed. [%s]', $invitation->getEmail()), $e, self::class);
         throw $e;
     }
 }
Esempio n. 2
0
 public function processSendKey(Form $form)
 {
     $value = $form->getValues();
     try {
         $invitation = $this->userManager->createInvitation($value['email']);
     } catch (UserAlreadyExistsException $uae) {
         $this->flashMessage('Pozvánku nelze odeslat. Uživatel s E-Mailem ' . $value['email'] . ' je již zaregistrován.', 'warning');
         $this->redirect('this');
     } catch (InvitationAlreadyExistsException $iae) {
         $this->flashMessage('Pozvánka již byla odeslána uživateli s E-mailem ' . $value['email'], 'warning');
         $this->redirect('this');
     }
     try {
         $this->emailNotifier->send('Výčetkový systém <' . $this->emails['system'] . '>', $invitation->email, function (ITemplate $template, Invitation $invitation, $senderName) {
             $template->setFile(__DIR__ . '/../../model/Notifications/templates/invitation.latte');
             $template->invitation = $invitation;
             $template->username = $senderName;
         }, [$invitation, $this->getUser()->getIdentity()->username]);
         $this->flashMessage('Registrační pozvánka byla odeslána', 'success');
     } catch (InvalidStateException $e) {
         $this->userManager->removeInvitation($invitation);
         Debugger::log($e, Debugger::ERROR);
         $this->flashMessage('Registrační pozvánku nebylo možné odeslat. Zkuste to prosím později.', 'error');
     }
     $this->redirect('this');
 }
Esempio n. 3
0
 public function processPasswordReset(Form $form)
 {
     $values = $form->getValues();
     try {
         $user = $this->userManager->resetPassword($values['email']);
     } catch (\Exceptions\Runtime\UserNotFoundException $u) {
         $form->addError('Nelze obnovit heslo na zadaném E-mailu.');
         return;
     }
     try {
         $this->emailNotifier->send('Výčetkový systém <' . $this->systemEmail . '>', $user->email, function (ITemplate $template, $email, $token) {
             $template->setFile(__DIR__ . '/../../model/Notifications/templates/resetEmail.latte');
             $template->email = $email;
             $template->token = $token;
         }, [$user->email, $user->token]);
         $this->flashMessage('Na Váš registrační E-Mail byly odeslány instrukce ke změně hesla.', 'success');
     } catch (Nette\InvalidStateException $e) {
         Debugger::log($e, Debugger::ERROR);
         $this->flashMessage('Při zpracování došlo k chybě. Zkuste prosím akci opakovat později.', 'error');
     }
     $this->redirect('Account:default');
 }