summaryrefslogtreecommitdiff
path: root/pages/api
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api')
-rw-r--r--pages/api/reauthenticate.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/pages/api/reauthenticate.php b/pages/api/reauthenticate.php
index e726e8e..fe10d28 100644
--- a/pages/api/reauthenticate.php
+++ b/pages/api/reauthenticate.php
@@ -1,7 +1,7 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn;
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE;
header("Content-Type: text/plain");
@@ -12,14 +12,24 @@ if (!$isLoggedIn || $isLowerLoggedIn) {
$newToken = generateToken();
-if (isset($_COOKIE['PEH2_SESSION_TOKEN'])) {
+if (isset($_COOKIE['PEH2_SESSION_TOKEN']) && $isLoggedIn) {
$old = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $_COOKIE['PEH2_SESSION_TOKEN']), true);
$old["name"] = base64_decode($_GET["name"] ?? "LQo=");
$old["created"] = time();
$old["addresses"] = [];
$old["last"] = time();
+ $old["profile"] = $_PROFILE;
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $newToken, json_encode($old));
+} else if (isset($_COOKIE['PEH2_SESSION_TOKEN']) && $isLowerLoggedIn) {
+ $old = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/lowertokens/" . $_COOKIE['PEH2_SESSION_TOKEN']), true);
+ $old["name"] = base64_decode($_GET["name"] ?? "LQo=");
+ $old["created"] = time();
+ $old["addresses"] = [];
+ $old["last"] = time();
+ $old["profile"] = $_PROFILE;
+
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/lowertokens/" . $newToken, json_encode($old));
}
die($newToken); \ No newline at end of file