lliure / permission
Data encryption package
v1.0.0
2023-06-01 17:20 UTC
Requires
- php: >= 8.0
- ext-openssl: *
This package is auto-updated.
Last update: 2024-11-30 02:19:02 UTC
README
Package for validating permissions with two levels
The first step to perform your tests is to create a class using the trait LlPermission\Permission.
File exPermission.php
<?php
class exPermission {
use \LlPermission\Permission;
}
The second step is to build the object with the user's permissions.
$permissions = (new \LlPermission\PermissionSet())
->setRole('use');
$permissions->setClass(exPermission::class)
->setScope('read')
->setScopes(['create', 'delete']);
Finally, you can perform tests using the created class exPermission, which receives the created object as a parameter.
$testPermission = new exPermission($permissions);
if (!$testPermission->create()) {
throw new Exception('Unauthorized', 401);
}
echo 'Hello world!';
Please note that this translation assumes that the code provided is correct and functions as intended.