/** * Login form factory. * @return \Nette\Application\UI\Form */ protected function createComponentLoginForm() { $form = new Nette\Application\UI\Form(); $form->setMethod('POST'); $form->addText('email', 'E-mail:')->setRequired('You have to input your e-mail!')->setAttribute('type', 'email')->setAttribute('placeholder', 'E-mail')->setAttribute('class', 'text'); $form->addPassword('password', 'Password:'******'You have to input password!')->setAttribute('placeholder', 'Password')->setAttribute('class', 'text'); $form->addCheckbox('remember', ' Keep me logged in for 2 week...'); $form->addSubmit('submit', 'Log in...')->setAttribute('class', 'button'); // call method signInFormSucceeded() on success $form->onSuccess[] = function (Nette\Application\UI\Form $form, $values) { if ($values->remember) { $this->getUser()->setExpiration('14 days', false, true); } else { $this->getUser()->setExpiration('20 minutes', true, true); } try { $this->getUser()->login($values->email, $values->password); $this->usersFacade->cleanForgottenPasswords($this->getUser()->id); $this->flashMessageLoginSuccess(); $this->finalRedirect(); } catch (Nette\Security\AuthenticationException $e) { $form->addError($e->getMessage()); } }; return $form; }