Merge pull request #46 from ThomasRubini/is_admin

This commit is contained in:
Thomas Rubini 2023-01-20 20:52:38 +01:00 committed by GitHub
commit c55ad5e1be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,11 +65,17 @@ final class Session
}
}
public static function is_admin(){
if (!self::is_login()) return false;
$O_userModel = new UserModel();
return $O_userModel->isUserAdmin($_SESSION["ID"]);
}
public static function admin_or_die(){
Session::login_or_die();
$O_userModel = new UserModel();
if (!$O_userModel->isUserAdmin($_SESSION["ID"])) {
if (!self::is_admin()) {
header("Location: /");
die();
}