drago-ex / project-user
A small helper package for working with the authenticated user in Drago project.
Package info
github.com/drago-ex/project-user
Type:drago-tools-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: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
The signed-in user of Drago Project with typed access to the identity data (username, email).
Requirements
- PHP >= 8.3, < 9
- Drago Project
Installation
composer require drago-ex/project-user
Project Tools copies the files of the package into
app/Core/Security, where you adapt them. UserConf.neon replaces the Nette user service with
App\Core\Security\CurrentUser, so $user in presenters and templates is CurrentUser.
Usage
use App\Core\Security\CurrentUser; use Nette\DI\Attributes\Inject; final class SomePresenter extends Presenter { #[Inject] public CurrentUser $currentUser; }
$identity = $currentUser->getUserIdentity(); echo $identity->username; echo $identity->email;
{varType App\Core\Security\CurrentUser $user} <p>{$user->getUserIdentity()->username}</p>
UserIdentityException is thrown when the identity data is missing or invalid. Extend UserIdentity with
further fields your project stores in the identity.