Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AdminModule;
  4.  
  5. use Nette;
  6. use Nette\Environment;
  7. use Nette\Application\AppForm;
  8. use Nette\Forms\Form;
  9.  
  10.  
  11. final class AuthPresenter extends BasePresenter
  12. {
  13.  
  14. /** @persistent */
  15. public $backlink = '';
  16.  
  17. protected function createComponentLoginForm($name)
  18. {
  19. $form = new AppForm($this, $name);
  20. // $form = new BaseForm();
  21.  
  22. $form->addText('login', 'Login:')
  23. ->addRule(Form::FILLED, 'Prosím zadajte login.');
  24.  
  25. $form->addPassword('password', 'Password:')
  26. ->addRule(Form::FILLED, 'Prosím zadajte heslo.');
  27.  
  28. $form->addProtection('Znova!');
  29. $form->addSubmit('send', 'Log in!');
  30.  
  31. $form->onSubmit[] = array($this, 'loginFormSubmitted');
  32. }
  33.  
  34. public function loginFormSubmitted($form)
  35. {
  36. try {
  37. $user = Environment::getUser();
  38. $user->login($form['login']->value, $form['password']->value);
  39. $this->getApplication()->restoreRequest($this->backlink);
  40. $this->redirect('Default:default');
  41.  
  42. } catch (AuthenticationException $e) {
  43. $form->addError($e->getMessage());
  44. }
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement