Inheritance: use trait Nette\SmartObject
Esempio n. 1
0
 /**
  * @return Nette\Application\UI\Form
  */
 protected function createComponentSignInForm()
 {
     $form = $this->signInFactory->create();
     $form->onSuccess[] = function (Form $form) {
         try {
             $this->user->setExpiration($form->values->remember ? '14 days' : '20 minutes');
             $this->getUser()->login($form->values->username, $form->values->password);
         } catch (AuthenticationException $e) {
             $form->addError($e->getMessage());
         }
         $this->restoreRequest($this->backlink);
         $this->redirect('Homepage:');
     };
     return $form;
 }
Esempio n. 2
0
 /**
  * Sign-in form factory.
  * @return Nette\Application\UI\Form
  */
 protected function createComponentSignInForm()
 {
     $form = $this->factoryIn->create();
     $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;
 }
Esempio n. 3
0
 /**
  * Sign-in form factory.
  * @return Nette\Application\UI\Form
  */
 protected function createComponentSignInForm()
 {
     return $this->signInFactory->create(function () {
         $this->redirect('Homepage:');
     });
 }