diff options
Diffstat (limited to 'pages/api/reauthenticate.php')
-rw-r--r-- | pages/api/reauthenticate.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pages/api/reauthenticate.php b/pages/api/reauthenticate.php new file mode 100644 index 0000000..50657cc --- /dev/null +++ b/pages/api/reauthenticate.php @@ -0,0 +1,19 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; + +header("Content-Type: text/plain"); + +if (!$isLoggedIn || $isLowerLoggedIn) { + header("Location: /-/login"); + die(); +} + +$newToken = generateToken(); + +if (isset($_COOKIE['PEH2_SESSION_TOKEN'])) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $newToken, file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $_COOKIE['PEH2_SESSION_TOKEN'])); +} + +die($newToken);
\ No newline at end of file |