szurubooru/src/Controllers/AuthController.php

37 lines
764 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()
{
2014-05-16 21:38:33 +02:00
try
{
$suppliedName = InputHelper::get('name');
$suppliedPassword = InputHelper::get('password');
$remember = boolval(InputHelper::get('remember'));
Auth::login($suppliedName, $suppliedPassword, $remember);
}
catch (SimpleException $e)
{
\Chibi\Util\Headers::setCode(400);
2014-05-16 21:38:33 +02:00
Messenger::fail($e->getMessage());
$this->renderView('auth-login');
}
2014-05-04 13:40:33 +02:00
2014-05-16 21:38:33 +02:00
$this->redirectToLastVisitedUrl('auth');
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
}