Commit 47065f37 authored by Mpro's avatar Mpro

remove sign presenter

parent 0078c5a9
<?php
namespace App\Presenters;
use Nette,
App\Model;
/**
* Sign in/out presenters.
*/
class SignPresenter extends BasePresenter
{
/**
* Sign-in form factory.
* @return Nette\Application\UI\Form
*/
protected function createComponentSignInForm()
{
$form = new Nette\Application\UI\Form;
$form->addText('username', 'Username:')
->setRequired('Please enter your username.');
$form->addPassword('password', 'Password:')
->setRequired('Please enter your password.');
$form->addCheckbox('remember', 'Keep me signed in');
$form->addSubmit('send', 'Sign in');
// call method signInFormSucceeded() on success
$form->onSuccess[] = $this->signInFormSucceeded;
return $form;
}
public function signInFormSucceeded($form, $values)
{
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('Homepage:');
} catch (Nette\Security\AuthenticationException $e) {
$form->addError($e->getMessage());
}
}
public function actionOut()
{
$this->getUser()->logout();
$this->flashMessage('You have been signed out.');
$this->redirect('in');
}
}
{block content}
<h1 n:block=title>Sign in</h1>
{control signInForm}
{* or use {include '../components/form.latte', form => signInForm} *}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment