szurubooru/src/Controllers/AuthController.php

34 lines
718 B
PHP
Raw Normal View History

2013-10-05 12:55:03 +02:00
<?php
2014-05-16 21:38:33 +02:00
class AuthController extends AbstractController
2013-10-05 12:55:03 +02:00
{
public function loginView()
2013-10-05 12:55:03 +02:00
{
2014-05-01 16:12:37 +02:00
if (Auth::isLoggedIn())
2014-05-16 21:38:33 +02:00
$this->redirectToLastVisitedUrl('auth');
else
$this->renderView('auth-login');
}
2013-10-05 12:55:03 +02:00
public function loginAction()
{
$success = $this->interceptErrors(function()
2014-05-16 21:38:33 +02:00
{
$suppliedName = InputHelper::get('name');
$suppliedPassword = InputHelper::get('password');
$remember = boolval(InputHelper::get('remember'));
Auth::login($suppliedName, $suppliedPassword, $remember);
});
2014-05-04 13:40:33 +02:00
if ($success)
$this->redirectToLastVisitedUrl('auth');
else
$this->renderView('auth-login');
2013-10-05 12:55:03 +02:00
}
public function logoutAction()
{
2014-05-01 16:12:37 +02:00
Auth::logout();
2014-05-16 21:38:33 +02:00
$this->redirectToLastVisitedUrl('auth');
2014-05-01 16:12:37 +02:00
}
2013-10-05 12:55:03 +02:00
}