From ae719995ee6d4e17e6626d4ff81584c7dd77736d Mon Sep 17 00:00:00 2001 From: shr3dd3r Date: Wed, 30 Aug 2023 05:16:15 +0300 Subject: [PATCH] api/user/__admin_session.php and random tweaks --- api/_auth.php | 10 +++++----- api/user/__admin_session.php | 23 +++++++++++++++++++++++ api/user/create.php | 4 ++++ api/user/delete.php | 14 +++++++++----- api/user/index.php | 2 +- config.json | 1 + docs/API.md | 1 + 7 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 api/user/__admin_session.php diff --git a/api/_auth.php b/api/_auth.php index 7e7ca13..04a6bf3 100644 --- a/api/_auth.php +++ b/api/_auth.php @@ -21,7 +21,7 @@ function EndSession () { $LOGGED_IN = false; -if (isset($_SESSION["userid"])) { +if (session_status() == PHP_SESSION_ACTIVE && isset($_SESSION["userid"])) { // Check if user still exist $s = $db->prepare("SELECT * FROM users WHERE id = ?"); $s->bind_param("s", $_SESSION["userid"]); @@ -32,10 +32,10 @@ if (isset($_SESSION["userid"])) { die("user id used in session does not exist"); } $LOGGED_IN = true; -} else { - if (session_status()) { - EndSession(); - } +} elseif (session_status() == PHP_SESSION_ACTIVE && !isset($_SESSION["userid"])) { + echo "no userid, destroying session"; + EndSession(); + die("no userid in session"); } ?> \ No newline at end of file diff --git a/api/user/__admin_session.php b/api/user/__admin_session.php new file mode 100644 index 0000000..e67fa42 --- /dev/null +++ b/api/user/__admin_session.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/api/user/create.php b/api/user/create.php index 2039f8f..96d850d 100644 --- a/api/user/create.php +++ b/api/user/create.php @@ -26,6 +26,10 @@ function User_Create ($login, $password, $email = null, $invite_id = null, $avat if (ThisFileIsRequested(__FILE__)) { require_once("../_json.php"); + // Dirty hack for debugging purposes. Will be removed later + if ($Config["debug"]) + $_POST = $_REQUEST; + // If registration turned off if (!$Config["registration"]["active"]) { ReturnJSONError($Err_DP_RegClosed, "registrations are closed"); diff --git a/api/user/delete.php b/api/user/delete.php index e020a7b..430ddcb 100644 --- a/api/user/delete.php +++ b/api/user/delete.php @@ -1,4 +1,4 @@ -