public function __construct(Listing $listing, SharedListingNotification $sharedListingNotification, IItemsTableControlFactory $itemsTableControlFactory, MessagesFacade $messagesFacade, ListingFacade $listingFacade, UserManager $userManager, User $user)
 {
     $this->listing = $listing;
     $this->sharedListingNotification = $sharedListingNotification;
     $this->itemsTableControlFactory = $itemsTableControlFactory;
     $this->messagesFacade = $messagesFacade;
     $this->listingFacade = $listingFacade;
     $this->userManager = $userManager;
     $this->user = $user;
     $this->users = $this->userManager->findAllUsers([$this->user->id]);
 }
Exemple #2
0
 public function processUserRegistration(Form $form)
 {
     $values = $form->getValues();
     $forbiddenNames = array_flip(['systém', 'system', 'admin', 'administrator', 'administrátor']);
     if (array_key_exists(strtolower($values['username']), $forbiddenNames)) {
         $form->addError('Vámi zadané jméno nelze použít. Vyberte si prosím jiné.');
         return;
     }
     $values['ip'] = $this->getHttpRequest()->getRemoteAddress();
     $values['role'] = 'employee';
     $user = new User($values['username'], $values['password'], $values['email'], $values['ip'], $values['role']);
     try {
         $this->userManager->registerNewUser($user, $this->invitation);
         $this->flashMessage('Váš účet byl vytvořen. Nyní se můžete přihlásit.', 'success');
         $this->redirect('Account:default');
     } catch (InvitationValidityException $iu) {
         $this->flashMessage('Registrovat se může pouze uživatel s platnou pozvánkou.', 'warning');
         $this->redirect('Account:default');
     } catch (\Exceptions\Runtime\DuplicateUsernameException $du) {
         $form->addError('Vámi zvolené jméno vužívá již někdo jiný. Vyberte si prosím jiné jméno.');
     } catch (\Exceptions\Runtime\DuplicateEmailException $de) {
         $form->addError("Zadejte prosím jiný E-mail.");
     } catch (\DibiException $d) {
         $form->addError('Registraci nelze dokončit. Zkuste to prosím později.');
     }
 }
Exemple #3
0
 public function processSaveWholeName(Form $form, $values)
 {
     $user = $this->userManager->getUserByID($this->user->id);
     $user->name = $values['name'];
     $this->userManager->saveUser($user);
     $this->user->getIdentity()->name = $values['name'];
     $this->flashMessage('Vaše jméno bylo úspěšně změněno.', 'success');
     $this->redirect('this');
 }
Exemple #4
0
 /**
  * @Actions newMessage
  */
 protected function createComponentNewMessageForm()
 {
     $form = new Form();
     $form->addText('subject', 'Předmět', 35, 80)->setRequired('Vyplňte prosím předmět zprávy.');
     $form->addTextArea('message', 'Zpráva', 50, 12)->setRequired('Vyplňte prosím text zprávy.')->addRule(Form::MAX_LENGTH, 'Zpráva může obsahovat maximálně %d znaků.', 2000);
     $form->addMultiSelect('receivers', 'Příjemci', $this->userManager->findAllUsers([$this->user->id]), 13)->setRequired('Vyberte alespoň jednoho příjemce.');
     $form->addCheckbox('isSystemMessage', 'Odeslat jako systémovou zprávu');
     $form->addSubmit('send', 'Odeslat');
     $form->getElementPrototype()->id = 'new-message-form';
     $form->onSuccess[] = $this->processNewMessageForm;
     return $form;
 }
 /**
  * Performs an authentication against e.g. database.
  * and returns IIdentity on success or throws AuthenticationException
  * @return IIdentity
  * @throws AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($email, $password) = $credentials;
     try {
         $user = $this->userManager->findUserByEmail($email);
     } catch (\Exceptions\Runtime\UserNotFoundException $u) {
         throw new AuthenticationException('Zadali jste špatný email.');
     }
     if (!Passwords::verify($password, $user->password)) {
         throw new AuthenticationException('Zadali jste špatné heslo.');
     } elseif (Passwords::needsRehash($user->password)) {
         $user->password = Passwords::hash($password);
         $this->userManager->saveUser($user);
     }
     $info = array('lastLogin' => new \DateTime(), 'lastIP' => $this->httpRequest->getRemoteAddress());
     $user->assign($info);
     $this->userManager->saveUser($user);
     $arr = $user->getData();
     unset($arr['password']);
     return new Identity($user->userID, $user->role, $arr);
 }
 public function processChangePassword(Form $form)
 {
     $values = $form->getValues();
     if ($this->user->email != $values['email']) {
         $this->flashMessage('<strong>Chyba!</strong> Vámi zadaný E-mail nesouhlasí s E-mailem, na který byl zaslán požadavek o změnu hesla!', 'error');
         $this->redirect('this');
     }
     try {
         $this->user->resetToken();
         $this->user->password = $values['password'];
         $this->userManager->saveUser($this->user);
     } catch (\DibiException $e) {
         $this->flashMessage('<strong>Chyba!</strong> Při pokusu o změnu hesla došlo k chybě. Na nápravě se pracuje. Zkuste to prosím později.', 'error');
         $this->redirect('this');
     }
     $this->flashMessage('<strong>Úspěch!</strong> Heslo bylo změněno. Nyní se můžete přihlásit.', 'success');
     $this->redirect('Account:default');
 }