<?php
declare(strict_types=1);
session_start();
require_once __DIR__ . '/permissions.php';

$username = $_SESSION['username'] ?? 'admin';
[$USER_ROLES, $PERMS] = resolveUserPermissions($username);

function canp(string $key): bool {
  global $PERMS;
  return can($PERMS, $key) || can($PERMS, '*');
}
function require_perm(string $key): void {
  if (!canp($key)) { http_response_code(403); exit('Access denied'); }
}
