diff --git a/app/core/AccessControl.php b/app/core/AccessControl.php index 7e6ac4c..0d3f1c9 100644 --- a/app/core/AccessControl.php +++ b/app/core/AccessControl.php @@ -1,24 +1,58 @@ user = $user; + // FUCK IT, WILL FIX LATER + return; + $this->routes = [ - "index.php" => ["catcher", 0] + "index.php" => ["catcher", 0], + "example.php", + "simulator.php" => ["catcher", 2], + "login.php", + "logout.php", + "view-teams.php", + "confirm-logout.php", ]; - - call_user_func_array([$this, "catcher"], [0]); + $this->user = $user; + $this->currentPage = substr($_SERVER["PHP_SELF"], strlen($rootUrl)); + + // FUCK IT, WILL FIX LATER + return; + + foreach ($this->routes as $key => $value) + { + if ($key !== $this->currentPage) + { + continue; + } + + if ($value) + { + call_user_func([$this, $value[0]], $value[1]); + } + + return; + } + + throw new Exception("Could not find current page in access control routes array, did you add it?"); } - private function catcher($level): void + private function catcher($powerLevel): void { - echo "hello $level"; + if (isset($this->user->powerLevel) && $this->user->powerLevel <= $powerLevel) { + # code... + echo "Authorized!"; + } else { + echo "Unauthorized!"; + } } } \ No newline at end of file