summaryrefslogtreecommitdiff
path: root/pages/api/reauthenticate.php
blob: 50657cc9f7b61c635a1221e8d0af7af705e4f342 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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);