Пример #1
0
include "env.php";
include APP_PATH . "/Bootstrap.php";
$authHelper = AuthHandler::getAuthenticationHelper();
// XXX: Implement!
$interactiveMode = $authHelper instanceof IAuthenticationHelperInteractive;
// This is a post - form submitted
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!AuthHandler::isSessionExisting()) {
        // Try to discard bots by dropping requests with no session
        die;
    }
    try {
        if (!$authHelper->validateForm($_POST)) {
            GlobalMessage::setGlobalMessage(_('Failed to authenticate') . ': ' . _('Please fill in all the required details.'), GlobalMessage::ERROR);
        } else {
            if (AuthHandler::authenticate($authHelper, $_POST) !== false) {
                // Redirect to original page
                if (!isset($ref)) {
                    $ref = 'index.php';
                }
                Utils::redirect($ref);
            } else {
                GlobalMessage::setGlobalMessage(_('Failed to authenticate') . ': ' . _('Incorrect credentials.'), GlobalMessage::ERROR);
            }
        }
    } catch (Exception $e) {
        logException($e);
        GlobalMessage::setGlobalMessage(_('Failed to authenticate') . ': ' . _('Internal error.'), GlobalMessage::ERROR);
    }
    // GET after POST
    Utils::redirect('auth.php');