If we login via the apikey, show it in the session

If we add a zone via the api, and the owner doesn't exist yet, create it.
This commit is contained in:
Mark Schouten 2014-09-26 14:02:22 +02:00
parent 262e3c76a8
commit 7f35f25869
2 changed files with 20 additions and 1 deletions

View file

@ -13,12 +13,13 @@ function is_logged_in() {
global $adminapikey;
global $adminapiips;
if (isset($adminapikey) && isset($allowedips)) {
if (isset($adminapikey) && isset($adminapiips)) {
if (array_search($_SERVER['REMOTE_ADDR'], $adminapiips) !== FALSE) {
if ($_POST['adminapikey'] == $adminapikey) {
# Allow this request, fake that we're logged in.
set_logged_in('admin');
set_is_adminuser();
$_SESSION['apientrance'] = 'true';
return TRUE;
}
}
@ -27,6 +28,17 @@ function is_logged_in() {
}
}
function set_apiuser() {
$_SESSION['apientrance'] = 'true';
}
function is_apiuser() {
if (isset($_SESSION['apientrance']) && $_SESSION['apientrance'] = 'true') {
return TRUE;
}
return FALSE;
}
function set_logged_in($login_user) {
$_SESSION['logged_in'] = 'true';
$_SESSION['username'] = $login_user;