Inheritance: extends Nette\Object
Example #1
0
 /**
  * Sign-up form factory.
  * @return Nette\Application\UI\Form
  */
 protected function createComponentSignUpForm()
 {
     // $httpRequest = $this->getHttpRequest();
     $params = $this->params;
     $to = NULL;
     if (array_key_exists('to', $params)) {
         $to = $params['to'];
     }
     $form = $this->factoryUp->create($to);
     $form->onSuccess[] = function ($form) {
         $httpRequest = $form->getPresenter()->getHttpRequest();
         $httpResponse = $form->getPresenter()->getHttpResponse();
         $cookie = $httpRequest->getCookie('to');
         $cookieTest = $httpRequest->getCookie('toTest');
         if (!empty($cookie)) {
             if ($cookie == 'new') {
                 $httpResponse->deleteCookie('to');
                 $form->getPresenter()->redirect('Test:new');
             }
             if ($cookie == 'test') {
                 $httpResponse->deleteCookie('to');
                 $form->getPresenter()->redirect('Test:test', array('id' => $cookieTest));
             }
         } else {
             $form->getPresenter()->redirect('Admin:');
         }
     };
     return $form;
 }
Example #2
0
 /**
  * Sign-up form factory.
  * @return Nette\Application\UI\Form
  */
 protected function createComponentSignUpForm()
 {
     $form = $this->signUpFactory->create();
     $form->onSuccess[] = function (Form $form) {
         $values = $form->getValues();
         $userByUserName = $this->usersRepository->getOneWhere(['username' => $values->username]);
         $error = 0;
         if (!is_null($userByUserName)) {
             $this->presenter->flashMessage("Uživatel s tímto username již existuje", 'error');
             $error = 1;
         }
         $userByEmail = $this->usersRepository->getOneWhere(['email' => $values->email]);
         if (!is_null($userByEmail)) {
             $this->presenter->flashMessage("Uživatel s tímto emailem již existuje", 'error');
             $error = 1;
         }
         if ($error == 0) {
             $user = new UsersEntity();
             if (trim($values->password) != '') {
                 $user->password(Passwords::hash($values->password));
             }
             $user->username($values->username);
             $user->name($values->name);
             $user->lastname($values->lastname);
             $user->email($values->email);
             $user->role($values->role);
             $this->usersRepository->save($user);
             $this->getUser()->login($values->username, $values->password);
             $this->flashMessage("Registrace proběhla v pořádku", 'success');
             $this->presenter->redirect('Homepage:default');
         }
     };
     return $form;
 }
Example #3
0
 /**
  * Sign-up form factory.
  * @return Nette\Application\UI\Form
  */
 protected function createComponentSignUpForm()
 {
     return $this->signUpFactory->create(function () {
         $this->redirect('Homepage:');
     });
 }