Semi-stable version with old variable names
This commit is contained in:
@@ -48,22 +48,41 @@ function verify_csrf() {
|
||||
die("Access Denied: Invalid CSRF Token.");
|
||||
}
|
||||
} else {
|
||||
http_response_code(403);
|
||||
http_response_code(405);
|
||||
die("Access Denied: Invalid Request Type.");
|
||||
}
|
||||
}
|
||||
|
||||
function verify_delete_csrf($_DELETE) {
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'DELETE') {
|
||||
$token = $_DELETE['csrf_token'] ?? '';
|
||||
if (!hash_equals($_SESSION['csrf_token'], $token)) {
|
||||
http_response_code(403);
|
||||
die("Access Denied: Invalid CSRF Token.");
|
||||
}
|
||||
} else {
|
||||
http_response_code(405);
|
||||
die("Access Denied: Invalid Request Type.");
|
||||
}
|
||||
}
|
||||
|
||||
$allowedUserTypes = ['trainer', 'kampfrichter', 'wk_leitung'];
|
||||
|
||||
function check_user_permission(string $type, bool $return = false) {
|
||||
function check_user_permission(string $type, bool $return = false, bool $display = false) {
|
||||
global $allowedUserTypes;
|
||||
|
||||
if (!in_array($type, $allowedUserTypes, true)) {
|
||||
if ($return) {
|
||||
return false;
|
||||
} else {
|
||||
http_response_code(403);
|
||||
die("Invalid User Type Configuration");
|
||||
if ($display) {
|
||||
http_response_code(403);
|
||||
include __DIR__ . "/../www/error-pages/403.html";
|
||||
exit;
|
||||
} else {
|
||||
http_response_code(403);
|
||||
die("Invalid User Type Configuration");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +96,14 @@ function check_user_permission(string $type, bool $return = false) {
|
||||
if ($return) {
|
||||
return false;
|
||||
} else {
|
||||
http_response_code(403);
|
||||
die("Access Denied");
|
||||
if ($display) {
|
||||
http_response_code(403);
|
||||
include __DIR__ . "/../www/error-pages/403.html";
|
||||
exit;
|
||||
} else {
|
||||
http_response_code(403);
|
||||
die("Access Denied");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user