drago-ex / project-user
A small helper package for working with the authenticated user in Drago project.
Installs: 56
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:drago-project-resource
pkg:composer/drago-ex/project-user
Requires
- php: >=8.3 <9
- nette/application: ^3.2
- nette/security: ^3.2
Requires (Dev)
- phpstan/phpstan-nette: ^1.2.9
README
A small helper package for working with the authenticated user in Drago project. Provides type-safe access to identity data and a simple, extensible user identity object.
Requirements
- PHP >= 8.3
- Nette Framework
- Drago Project core packages
Install
composer require drago-ex/project-user
Usage
Injecting the user service:
use App\Core\User\UserAccess; use Nette\DI\Attributes\Inject; final class SomePresenter extends Presenter { #[Inject] public UserAccess $userAccess; protected function beforeRender(): void { parent::beforeRender(); $this->template->userAccess = $this->userAccess; } }
Identity data in latte
{varType App\Core\User\UserAccess $userAccess} {block content} <p>{$userAccess->getUserIdentity()->username}</p> {/block}
User identity object
For common identity fields, use the typed UserIdentity object:
$identity = $userAccess->getUserIdentity(); echo $identity->username; echo $identity->email;
The UserIdentity class is intentionally simple and can be extended with additional attributes (e.g. id, roles, permissions) as needed.
UserIdentityException is thrown when identity data is missing or invalid.
Notes
- This package does not handle authentication or authorization.
- Focused only on safe and convenient access to user identity data.