authenticate() статический публичный Метод

static public authenticate ( )
Пример #1
0
} else {
    # Dedicated server mode
    define("PROJECT_PATH_ROOT", dirname(dirname(getcwd())) . "/");
    #../../
}
if (!file_exists(PROJECT_PATH_ROOT . 'vendor/')) {
    die('<h1>Incomplete installation</h1><p>Ba&iuml;kal dependencies have not been installed. Please, execute "<strong>composer install</strong>" in the folder where you installed Ba&iuml;kal.');
}
require PROJECT_PATH_ROOT . 'vendor/autoload.php';
# Bootstraping Flake
\Flake\Framework::bootstrap();
# Bootstrap BaikalAdmin
\BaikalAdmin\Framework::bootstrap();
# Assert that BaikalAdmin is enabled
\BaikalAdmin\Core\Auth::assertEnabled();
# Create and setup a page object
$oPage = new \Flake\Controller\Page(BAIKALADMIN_PATH_TEMPLATES . "Page/index.html");
$oPage->injectHTTPHeaders();
$oPage->setTitle("Baïkal " . BAIKAL_VERSION . " Web Admin");
$oPage->setBaseUrl(PROJECT_URI);
# Authentication
if (\BaikalAdmin\Core\Auth::isAuthenticated() === FALSE && \BaikalAdmin\Core\Auth::authenticate() === FALSE) {
    $oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Topbar\Anonymous());
    $oPage->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Login());
} else {
    $oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Topbar());
    # Route the request
    $GLOBALS["ROUTER"]::route($oPage);
}
# Render the page
echo $oPage->render();
Пример #2
0
}
if (!file_exists(PROJECT_PATH_ROOT . 'vendor/')) {
    die('<h1>Incomplete installation</h1><p>Ba&iuml;kal dependencies have not been installed. Please, execute "<strong>composer install</strong>" in the folder where you installed Ba&iuml;kal.');
}
require PROJECT_PATH_ROOT . 'vendor/autoload.php';
# Bootstraping Flake
\Flake\Framework::bootstrap();
# Bootstrap BaikalAdmin
\BaikalAdmin\Framework::bootstrap();
# Create and setup a page object
$oPage = new \Flake\Controller\Page(BAIKALADMIN_PATH_TEMPLATES . "Page/index.html");
$oPage->injectHTTPHeaders();
$oPage->setTitle("Baïkal " . BAIKAL_VERSION . " Web Admin");
$oPage->setBaseUrl(PROJECT_URI);
if (!\BaikalAdmin\Core\Auth::isAuthenticated()) {
    if (\BaikalAdmin\Core\Auth::authenticate()) {
        // Redirect to itself
        header('Location: ' . $_SERVER['REQUEST_URI']);
        exit;
    } else {
        // Draw login page
        $oPage->zone("navbar")->addBlock(new \BaikalAdmin\Controller\Navigation\Topbar\Anonymous());
        $oPage->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Login());
    }
} else {
    // CSRF token check
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        if (!isset($_POST['CSRF_TOKEN'])) {
            throw new \Exception('CSRF token was not submitted. Try removing your cookies and log in again');
        }
        if ($_POST['CSRF_TOKEN'] !== $_SESSION['CSRF_TOKEN']) {