Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Log presenter.
- *
- * @author Roland "DOBss" Dobos
- * @package Pekarstvo.sk
- */
- namespace FrontModule;
- use \Nette\Security as NS, \dibi;
- class LogPresenter extends BasePresenter{
- public function actionIn(){
- if(!empty($_POST['login']) && !empty($_POST['pw'])){
- try{
- $user = $this->getUser();
- $pass = \User::hashPassword($_POST['pw']);
- $this->getUser()->setExpiration('+ 14 days', FALSE);
- $user->login($_POST['login'], $pass);
- if ($this->isAjax()){
- $this->payload->message = 'ok';
- $this->terminate();
- }
- }catch(NS\AuthenticationException $e){
- if ($this->isAjax()){
- $this->payload->message = $e->getMessage();
- $this->terminate();
- }else
- $this->flashMessage($e->getMessage(), "success");
- }
- }else if($this->isAjax()){ $this->payload->message = 'Musíte vyplniť všetky polia.'; $this->terminate(); }
- }
- public function actionOut(){
- $this->getUser()->logout();
- if ($this->isAjax()){ $this->payload->message = 'ok'; $this->terminate(); }
- else $this->flashMessage("Boli ste úspešne odhlásený", "success");
- }
- public function beforeRender(){
- $this->redirect("Homepage:");
- }
- }
Add Comment
Please, Sign In to add comment