Merge branch 'fix/rbac_init' into 'main'

Comprobar que el directorio RBAC existe y añadido .gitkeep

See merge request jjimenez/safekat!694
This commit is contained in:
Ignacio Martinez Navajas
2025-04-12 19:11:48 +00:00

View File

@ -29,8 +29,12 @@ if (!function_exists('generate_php_roles_constant')) {
// Close the array
$phpCode .= "];\n";
// Write PHP code to a file
$filePath = APPPATH . "Config/RBAC/roles.php";
$dirPath = APPPATH . "Config/RBAC";
if (!is_dir($dirPath)) {
mkdir($dirPath, 0775, true); // true permite crear carpetas anidadas
}
$filePath = $dirPath . "/roles.php";
file_put_contents($filePath, $phpCode);
}
@ -58,9 +62,14 @@ if (!function_exists('generate_php_permissions_constant')) {
// Close the array
$phpCode .= "];\n";
// Write PHP code to a file
$filePath = APPPATH . "Config/RBAC/permissions.php";
$dirPath = APPPATH . "Config/RBAC";
if (!is_dir($dirPath)) {
mkdir($dirPath, 0775, true); // true permite crear carpetas anidadas
}
$filePath = $dirPath . "/permissions.php";
file_put_contents($filePath, $phpCode);
}
}
@ -87,8 +96,12 @@ if (!function_exists('generate_php_permissions_matrix_constant')) {
// Close the array
$phpCode .= "];\n";
// Write PHP code to a file
$filePath = APPPATH . "Config/RBAC/permissionMatrix.php";
$dirPath = APPPATH . "Config/RBAC";
if (!is_dir($dirPath)) {
mkdir($dirPath, 0775, true); // true permite crear carpetas anidadas
}
$filePath = $dirPath . "/permissionMatrix.php";
file_put_contents($filePath, $phpCode);
}
}
@ -130,9 +143,9 @@ if (!function_exists('checkGroups')) {
*/
function checkGroups(array $groups, string $redirectRoute = null)
{
$session = \Config\Services::session();
$session = \Config\Services::session();
$response = \Config\Services::response();
$auth = auth(); // Shield auth service
$auth = auth(); // Shield auth service
$user = $auth->user();