Download the PHP package med-ezzairi/account-module without Composer
On this page you can find all versions of the php package med-ezzairi/account-module. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download med-ezzairi/account-module
More information about med-ezzairi/account-module
Files in med-ezzairi/account-module
Package account-module
Short Description A module letting you make Account management easy, including users, groups, permissions & roles
License MIT
Informations about the package account-module
Account Module
This module lets you manage Groups of users, setup groups permissions and per user permissions, the reason behind this module is that you are free to define permissions in your config file as text and assign them to groups or users as you need. The final result is that you could check the user permission based on text (permission) you defined not ids (auto increment) used by other packages/modules.
Installation
This module requires using the package nwidart/laravel-modules see the page nwidart/laravel-modules.
Config and Migration
Check the config file under Modules/Account/Config/account.php to setup tables names.
Update the Model/Entity User in general under app/Models/User
Update the Model User to use the trait Modules\Account\Traits\UserUsingGroupsAndPermissions;
as follow:
Usage
- Permission definition
Check the file Modules/Account/Config/permissions.php to see the permissions definition.
The definition follows the:
- Permission assignment
Check the url: http://yourapplication/account (like: http://localhost/account)
- Permission verification
After Permission definition and assignment we could check the User's permission by calling the helper allowed(permission_name), like this allowed('shop.orders.delete'); from any where in your code (controller, service or repository). If the connected user is allowed the code will continue execution, if not allowed an exception will be thrown (check the Modules\Account\Exceptions\AuthorizationException)
- Per Resource Permission
We have a logic to handle per-resource-permissions for specific Resources/Models/Entities. To use the ResourcePermission, add the trait Modules\Account\Traits\HasResourcePermission to the resource/model/entity and specify the protected $resourcePermission attribute.
In the OrderResourcePermission we need to create a method that will handle the permission logic, the method name must be same permission action, example shop.orders.delete (the action here is: delete)
To check if the connect user is able/permitted to perform the requested action/permission on a resource, use the same helper, like this allowed('shop.orders.delete', $order);. Here we passed the resource as the second parameter.
Note: Be careful with per-resource-permission, the user should already has the permission to perform the action (direct permission assignment or assigned via group) and after checking the permission we will check if he is permitted for that action on that resource.
Tests
Sorry, no tests are provided for now.
Specific Help or Custom Integration
Please let me know about your need and I will help you.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.