Example #1
0
<?php

require_once "vendor/autoload.php";
require_once "config.php";
require_once "oeauth.php";
$oe = new OEAuth($config["oe"]["url"], $config["oe"]["dbname"]);
$bad_login = False;
$is_auth = $oe->is_auth();
$was_auth = $is_auth;
if ($is_auth) {
    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "logout") {
        $oe->deauthenticate();
        $is_auth = False;
    }
} else {
    if (isset($_POST["action"])) {
        $oe->authenticate($_POST);
        $is_auth = $oe->is_auth();
        if (!$is_auth) {
            $bad_login = True;
        }
    }
}
$authentication_msg = "<p id='status'>You are " . ($is_auth ? "<span class='green'>authentified</span>" : "unknown") . " here, on  " . $_SERVER['HTTP_HOST'] . "</p>";
if (!$is_auth) {
    // refresh toward a login page/widget
    $form_content = "login: <input type='text' name='login' /><br/>";
    $form_content .= "password: <input type='text' name='password' /><br/>";
    $form_content .= "<input type='submit' name='action' value='login' />";
} else {
    $form_content = "<input type='submit' name='action' value='logout' />";
<?php

require_once "config.php";
require_once "oeauth.php";
header('Access-Control-Allow-Origin: ' . $_REQUEST["origin"]);
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Allow-Headers: origin, content-type, accept');
$oe = new OEAuth($config["oe"]["url"], $config["oe"]["dbname"]);
$oe->authTokenStore->set($oe->authWebTransmitter->read_tokens_from_request());
if ($oe->is_auth()) {
    echo "AUTH";
} else {
    echo "DEAUTH";
}