Example #1
0
// -----------------------------------------------------------------------------
// Logging in
// -----------------------------------------------------------------------------
// Already logged in?
if (Authentication::current_user() !== false) {
    Util::redirect(@$_REQUEST['redirect']);
}
// Try to log in
if (isset($_REQUEST['login'], $_REQUEST['password'])) {
    try {
        Authentication::login($_REQUEST['login'], $_REQUEST['password']);
        Util::redirect(@$_REQUEST['redirect']);
    } catch (InternalException $e) {
        ErrorPage::die_fancy($e);
    } catch (Exception $e) {
        Template::add_message('login', 'error', "Incorrect username or password.");
        Log::info("Login failed for username '" . $_REQUEST['login'] . "'");
    }
}
// -----------------------------------------------------------------------------
// Login page
// -----------------------------------------------------------------------------
class View extends Template
{
    function title()
    {
        return "Log in";
    }
    function write_body()
    {
        $this->write_messages('login');