szurubooru/src/Controllers/AuthController.php
2014-05-20 23:12:24 +02:00

33 lines
718 B
PHP

<?php
class AuthController extends AbstractController
{
public function loginView()
{
if (Auth::isLoggedIn())
$this->redirectToLastVisitedUrl('auth');
else
$this->renderView('auth-login');
}
public function loginAction()
{
$success = $this->interceptErrors(function()
{
$suppliedName = InputHelper::get('name');
$suppliedPassword = InputHelper::get('password');
$remember = boolval(InputHelper::get('remember'));
Auth::login($suppliedName, $suppliedPassword, $remember);
});
if ($success)
$this->redirectToLastVisitedUrl('auth');
else
$this->renderView('auth-login');
}
public function logoutAction()
{
Auth::logout();
$this->redirectToLastVisitedUrl('auth');
}
}