Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AdminModule;
- use Nette;
- use Nette\Environment;
- use Nette\Application\AppForm;
- use Nette\Forms\Form;
- final class AuthPresenter extends BasePresenter
- {
- /** @persistent */
- public $backlink = '';
- protected function createComponentLoginForm($name)
- {
- $form = new AppForm($this, $name);
- // $form = new BaseForm();
- $form->addText('login', 'Login:')
- ->addRule(Form::FILLED, 'Prosím zadajte login.');
- $form->addPassword('password', 'Password:')
- ->addRule(Form::FILLED, 'Prosím zadajte heslo.');
- $form->addProtection('Znova!');
- $form->addSubmit('send', 'Log in!');
- $form->onSubmit[] = array($this, 'loginFormSubmitted');
- }
- public function loginFormSubmitted($form)
- {
- try {
- $user = Environment::getUser();
- $user->login($form['login']->value, $form['password']->value);
- $this->getApplication()->restoreRequest($this->backlink);
- $this->redirect('Default:default');
- } catch (AuthenticationException $e) {
- $form->addError($e->getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement