Files
breadcrumb-the-shire/pages/admin/tenants/index().php

30 lines
1.0 KiB
PHP

<?php
use MintyPHP\Buffer;
use MintyPHP\Service\Access\AccessServicesFactory;
use MintyPHP\Service\Access\TenantAuthorizationPolicy;
use MintyPHP\Support\Guard;
use MintyPHP\Session;
Guard::requireLogin();
$currentUserId = (int) ($_SESSION['user']['id'] ?? 0);
$authorizationService = (new AccessServicesFactory())->createAuthorizationService();
$decision = $authorizationService->authorize(TenantAuthorizationPolicy::ABILITY_ADMIN_TENANTS_VIEW, [
'actor_user_id' => $currentUserId,
]);
if (!$decision->isAllowed()) {
Guard::deny();
}
$capabilities = $decision->attribute('capabilities', []);
$canCreateTenants = is_array($capabilities) ? (bool) ($capabilities['can_create_tenant'] ?? false) : false;
Buffer::set('title', t('Tenants'));
Buffer::set('grid_lang', json_encode(gridLang(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
$csrfKey = Session::$csrfSessionKey;
$csrfToken = $_SESSION[$csrfKey] ?? '';
Buffer::set(
'grid_csrf',
json_encode(['key' => $csrfKey, 'token' => $csrfToken], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
);