Esempio n. 1
0
 /**
  * Registration form factory.
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentRegistrationForm()
 {
     CaptchaControl::register($this->getSession());
     $form = $this->factory->create();
     $form->onSuccess[] = function () {
         $this->redirect('Cabinet:cabinet', array('id' => $this->factory->getId()));
     };
     return $form;
 }
Esempio n. 2
0
 public function createComponentRegisterForm($name)
 {
     $form = new Form($this, $name);
     $form->onSuccess[] = callback($this, $name . 'Submitted');
     $login = $this->getContext()->config->get('user.login');
     $form->addText('name', 'Jméno')->setRequired('Prosím vyplňte své jméno');
     $form->addText('surname', 'Přijímení')->setRequired('Prosím vyplňte své přijímení');
     if ($login === 'username') {
         $form->addText('username', 'Uživatelské jméno:')->setRequired('Prosím vyplňte své uživatelské jméno.');
     }
     // we want the email anyway...
     $form->addText('email', 'E-mail:')->addRule(Form::EMAIL, 'Prosím vyplňte validní emailovou adresu.')->setRequired('Prosím vyplňte svou emailovou adresu.');
     $form->addPassword('password', 'Heslo:')->setRequired('Prosím vyplňte své heslo')->addRule(Form::MIN_LENGTH, 'Vaše heslo musí být dlouhé nejméně %d znaků.', $this->context->config->get('security.password.minLength', 6));
     $form->addPassword('passwordCheck', 'Heslo znovu pro kontrolu:')->setRequired('Prosím vyplňte své druhé helso pro kontrolu.')->addRule(Form::EQUAL, 'Vyplněná hesla se neshodují', $form['password']);
     $form->addCheckbox('newsletter', 'Mám zájem o pravidelné zasílání novinek')->setDefaultValue(true);
     \PavelMaca\Captcha\CaptchaControl::register();
     $form['captcha'] = new \PavelMaca\Captcha\CaptchaControl();
     $form['captcha']->caption = 'Security code:';
     $form['captcha']->setTextColor(Nette\Image::rgb(48, 48, 48));
     $form['captcha']->setBackgroundColor(Nette\Image::rgb(232, 234, 236));
     $form['captcha']->setRequired('Prosím opište bezpečnostní kód z obrázku');
     $form['captcha']->addRule($form["captcha"]->getValidator(), 'Bezpečnostní kód se neshoduje. Prosím zkuste to znovu.');
     $form->addSubmit('s', 'Registrovat!');
 }
 /**
  * Validate control. Do not call directly!
  * @param CaptchaControl
  * @return bool
  * @throws \Nette\InvalidStateException
  */
 public function validateCaptcha(CaptchaControl $control)
 {
     $parent = $control->getParent();
     $uidFieldName = $control->getUidFieldName();
     if (!isset($parent[$uidFieldName])) {
         throw new \Nette\InvalidStateException('Can\'t find ' . __CLASS__ . ' uid field ' . $uidFieldName . ' in parent');
     }
     $uid = $parent[$uidFieldName]->getValue();
     $sessionValue = $control->getSession($uid);
     $control->unsetSession($uid);
     return $sessionValue === $control->getValue();
 }
Esempio n. 4
0
 public function createComponentRetrievePasswordForm($name)
 {
     $form = new Form();
     $form->addProtection();
     $form->addText('email', 'E-mail:')->setEmptyValue('@')->addRule(Form::EMAIL, 'Zadaná e-mailová adresa není platná')->setRequired('Prosím vyplňte e-mail zadaný při registraci');
     \PavelMaca\Captcha\CaptchaControl::register();
     $form['captcha'] = new \PavelMaca\Captcha\CaptchaControl();
     $form['captcha']->caption = 'Bezpečnosntí kód:';
     $form['captcha']->setTextColor(Nette\Image::rgb(48, 48, 48));
     $form['captcha']->setBackgroundColor(Nette\Image::rgb(232, 234, 236));
     $form['captcha']->addRule(Form::FILLED, 'Přepište prosím bezpečnosntí kód');
     $form['captcha']->addRule($form["captcha"]->getValidator(), 'Zadaný bezpečnostní kód není správný. Přepište jej prosím pečlivě z obrázku vlevo.');
     $form->addSubmit('send', 'Zaslat heslo');
     $form->onSuccess[] = callback($this, $name . 'Submitted');
     $form->onError[] = callback($this, 'sendNewCaptcha');
     $form->onError[] = callback($this, 'ajaxFormErrors');
     return $form;
 }