Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Login presenter.
- *
- * @author Roland "DOBss" Dobos
- * @package Pekarstvo.sk
- */
- namespace AdminModule;
- use \Nette\Application\UI\Form;
- class LoginPresenter extends BasePresenter{
- public function beforeRender(){
- if($this->getUser()->isLoggedIn()) $this->redirect("Panel:");
- $this->template->h1c = 'mainc';
- // try{
- // $user = $this->getUser();
- // $pass = \User::hashPassword('himes0411');
- // $user->login('DOBss', $pass);
- // $this->flashMessage("Boli ste úspešne prihlásení","success");
- // }catch(\Nette\Security\AuthenticationException $e){
- // $this->flashMessage($e->getMessage(),"error");
- // }
- dump($this->getUser()->getIdentity());
- }
- public function actionOut(){
- $this->getUser()->logout();
- $this->flashMessage("Boli ste úspešne odhlásený", "success");
- $this->redirect("Login:");
- }
- public function createComponentLoginForm(){
- $form = new Form;
- $form->addText('login','Meno:');
- $form->addPassword('pass','Heslo:');
- $form->addsubmit('send','Prihlásiť:');
- $form->onSuccess[] = callback($this, 'loginFormSubmitted');
- return $form;
- }
- public function loginFormSubmitted(Form $form){
- if(empty($form->values->login) || empty($form->values->pass)) $this->flashMessage('Musíte vyplniť všetky polia',"error");
- else{
- try{
- // dump($form->values); exit;
- $user = $this->getUser();
- $pass = \User::hashPassword($form->values->pass);
- $user->login($form->values->login, $pass);
- $this->flashMessage("Boli ste úspešne prihlásení","success");
- // $this->redirect("Panel:");
- }catch(\Nette\Security\AuthenticationException $e){
- $this->flashMessage($e->getMessage(),"error");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment