From 94c57fa247ba107fce8fc1d1fc355191229dbddc Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 8 Aug 2021 22:31:51 +0200 Subject: Permissions system --- admin/callback/index.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'admin/callback') diff --git a/admin/callback/index.php b/admin/callback/index.php index 8816c32..5052369 100644 --- a/admin/callback/index.php +++ b/admin/callback/index.php @@ -36,7 +36,14 @@ if (isset($result["access_token"])) { $result = curl_exec($crl); $result = json_decode($result, true); - if ($result["id"] === "74bca7d2-4694-477c-8bc1-9003315abbee") { + $login = false; + foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/admin/private/permissions.json"), true) as $id => $user) { + if ($result["id"] === $id && in_array("login", $user)) { + $login = true; + } + } + + if ($login) { $token = bin2hex(random_bytes(32)); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/admin/private/tokens/" . $token, json_encode($result)); setcookie("ADMIN_TOKEN", $token, 0, "/", ".minteck.ro.lt", true, true); -- cgit