ACC SHELL

Path : /srv/www/vhosts/unisol/app/AdminModule/presenters/
File Upload :
Current File : //srv/www/vhosts/unisol/app/AdminModule/presenters/SignPresenter.php

<?php

namespace AdminModule;

use Nette\Application\UI;
use Nette\Security,
	Nette\Utils\Strings;
      
/**
 * Sign in/out presenters.
 */
class SignPresenter extends \BasePresenter
{


	/**
	 * Sign-in form factory.
	 * @return Nette\Application\UI\Form
	 */
   
     public function renderIn(){
            if ($this->user->isLoggedIn()) {
        $this->redirect('Dashboard:uvod');
    }
  }
	protected function createComponentSignInForm()
	{
		$form = new UI\Form;
 
 
		$form->addText('username', 'Jméno:')
			->setRequired('Vložte jméno.');

		$form->addPassword('password', 'Heslo:')
			->setRequired('Vložte heslo.');

		$form->addCheckbox('remember', 'Zůstat přihlášený');

		$form->addSubmit('send', 'Vstoupit');

		
		$form->onSuccess[] = $this->signInFormSucceeded;
		return $form;
	}


	public function signInFormSucceeded($form)
	{
		$values = $form->getValues();

		if ($values->remember) {
			$this->getUser()->setExpiration('14 days', FALSE);  
		} else {
			$this->getUser()->setExpiration('20 minutes', TRUE);
		}

		try {
			$this->getUser()->login($values->username, $values->password);
			$this->redirect('Dashboard:uvod');

				} catch (Security\AuthenticationException $e) {
      $form->addError($e->getMessage());
      
      
		}
	}


	public function actionOut()
	{
		$this->getUser()->logout();
		$this->flashMessage('Byl jste odhlášen.');
		$this->redirect('in');
	}

}

ACC SHELL 2018