Beispiel #1
0
function showSuccessScreen($db, $user)
{
    updateauthtoken($db);
    if (isset($_REQUEST['redirect'])) {
        error_log(__FILE__ . ": redirecting");
        header('Location: ' . $_REQUEST['redirect']);
        echo "Redirect!\n";
    }
    setDarwinUser($user);
    darwinHeader("Welcome", "Welcome - Login successful");
    echo "<p>Congratulations with successfully authenticating on darwin.</p>";
    darwinFooter();
}
Beispiel #2
0
/**
 * Try to get the user for the app, but don't use the database.
 * @return string The known user, or FALSE if there is none
 */
function pollDarwinUser($allowDB = TRUE)
{
    global $DARWIN__USER;
    if (isset($_SERVER['AP_MAD_UID'])) {
        // Set the user through server variables before trying to get the user ourselves
        $user = $_SERVER['AP_MAD_UID'];
    } else {
        if (isset($_SERVER['PHP_AUTH_USER'])) {
            $user = $_SERVER['PHP_AUTH_USER'];
        } else {
            if (function_exists('getDarwinUser') && $allowDB) {
                $user = getDarwinUser();
            } else {
                if (isset($DARWIN__USER) && $DARWIN__USER !== False) {
                    $user = $DARWIN__USER;
                } else {
                    $user = NULL;
                }
            }
        }
    }
    setDarwinUser($user);
    return $user;
}
Beispiel #3
0
    }
    // Actually unset the cookie
    setrawcookie($DARWINCOOKIENAME, '', $cookieexpire, '/', $host, $secure);
    if (isset($authtoken)) {
        $db = getAuthDb();
        $requestip = $_SERVER["REMOTE_ADDR"];
        $stmt = checkPrepare($db, 'DELETE FROM `tokens` WHERE `ip`=? AND `token`=?');
        checkBindParam($db, $stmt, "ss", $requestip, $authtoken);
        checkExecute($db, $stmt);
        $stmt->close();
        $db->commit();
        cleanTokens($db);
        $db->close();
    }
    // Whatever happens set the user for the rest of the page to null.
    setDarwinUser(NULL);
    if (isset($_REQUEST['redirect'])) {
        header('Location: ' . $_REQUEST['redirect']);
        exit;
        // Finished
    } else {
        if ($htmloutput) {
            showSuccessScreen();
        } else {
            echo "logout:{$user}";
        }
    }
} else {
    if (isset($_REQUEST['redirect'])) {
        header('Location: ' . $_REQUEST['redirect']);
        exit;