foowie / permission-checker
Access permission check & latte macros
Installs: 16 298
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: >=7.2
- latte/latte: ^2.10.8
- nette/nette: ^3.0
Requires (Dev)
- phpstan/phpstan: ^1.9
- phpstan/phpstan-deprecation-rules: ^1.1.1
- phpstan/phpstan-nette: ^1.2.3
README
Installation
Include extension in config.neon
extensions:
permission: Foowie\PermissionChecker\DI\PermissionExtension
and use PresenterPermissionTrait in your base presenter.
Usage
You can annotate presenter class, action and render methods and signal methods with these annotations:
@loggedIn - logged user is required
@loggedIn(false) - unlogged user is required
@role(superadmin, admin) - user must have role admin or superadmin
@resource(administration) - user must be assigned to administration resource
In template files is allowed to user these macros:
{ifAllowed 'administration'}{/ifAllowed} - user must be assigned to administration resource
{ifAllowedLink ':Administration:Dashboard:'}{/ifAllowed} - user must be allowed to display that page
<a n:ifAllowedHref=':Administration:Dashboard:'></a> - user must be allowed to display that page, shorter alternative is "allowedHref"