Files
breadcrumb-the-shire/lib/Support/helpers/auth.php
2026-02-11 19:28:12 +01:00

28 lines
741 B
PHP

<?php
function accountUrl(): string
{
$user = $_SESSION['user'] ?? [];
$uuid = (string) ($user['uuid'] ?? '');
return $uuid !== '' ? lurl('profile') : lurl('login');
}
function can(string $permissionKey): bool
{
$userId = (int) ($_SESSION['user']['id'] ?? 0);
if ($userId <= 0) {
return false;
}
if (!class_exists('MintyPHP\\Service\\Access\\PermissionService')) {
return false;
}
$keys = \MintyPHP\Service\Access\PermissionService::getCachedPermissions($userId);
if (!$keys) {
$keys = \MintyPHP\Service\Access\PermissionService::getUserPermissions($userId);
if (!$keys) {
return false;
}
}
return in_array($permissionKey, $keys, true);
}