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

static public isAuthenticated ( )
Пример #1
0
 public function render()
 {
     $sActionUrl = \Flake\Util\Tools::getCurrentUrl();
     $sSubmittedFlagName = "auth";
     $sMessage = "";
     if (self::isSubmitted() && !\BaikalAdmin\Core\Auth::isAuthenticated()) {
         $sMessage = \Formal\Core\Message::error("The login/password you provided is invalid. Please retry.", "Authentication error");
     } elseif (self::justLoggedOut()) {
         $sMessage = \Formal\Core\Message::notice("You have been disconnected from your session.", "Session ended", FALSE);
     }
     $sLogin = htmlspecialchars(\Flake\Util\Tools::POST("login"));
     $sPassword = htmlspecialchars(\Flake\Util\Tools::POST("password"));
     if (trim($sLogin) === "") {
         $sLogin = "******";
     }
     $oView = new \BaikalAdmin\View\Login();
     $oView->setData("message", $sMessage);
     $oView->setData("actionurl", $sActionUrl);
     $oView->setData("submittedflagname", $sSubmittedFlagName);
     $oView->setData("login", $sLogin);
     $oView->setData("password", $sPassword);
     return $oView->render();
 }
Пример #2
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();
Пример #3
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');
        }