tallieutallieu / dry-accounts
There is no license information available for the latest version (5.0.0) of this package.
Account system for DRY applications
5.0.0
2026-09-28 14:58 UTC
Requires
- php: ^8.4
- firebase/php-jwt: ^7.2.0
- tallieutallieu/dry: ^4.4.1
- tallieutallieu/dry-dbi: ^3.13.3
- tallieutallieu/dry-external-api: ^3.0.3
- tallieutallieu/oak: ^4.2.2
Requires (Dev)
- phpstan/phpstan: ^2.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- 5.0.0
- 4.0.1
- 4.0.0
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.20
- 2.0.19
- 2.0.18
- 2.0.17
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-chore/sc-11673--dry3-switch-active-packages-to-dry-ci
- dev-chore/sc-11672--dry3-backfill-changelog-md-for-active
- dev-feature/sc-9920--dry-accounts-add-two-factor-authentication
- dev-dry3
- dev-old-dry
This package is auto-updated.
Last update: 2026-09-28 14:58:42 UTC
README
Account system for DRY applications
Installation
composer require tallieutallieu/dry-accounts
php oak migration migrate -m account
Config options
All keys live under accounts..
| Name | Type | Default |
|---|---|---|
| model | dry\orm\Model | Tnt\Account\Model\User |
| storage | UserStorageInterface | SessionUserStorage |
| factory | UserFactoryInterface | UserFactory |
| repository | UserRepositoryInterface | UserRepository |
| auth_class | AuthenticationInterface | Authentication |
| use_legacy_hash | bool | false |
| reset_token_ttl | int (seconds) | 3600 (1 hour) |
| activation_token_ttl | int (seconds) | 604800 (7 days) |
| jwt_secret | string (min. 32 bytes) | — |
| token_expiry_time | int (seconds) | 3600 |
| refresh_token_expiry_time | int (seconds) | 7200 |
Reset and activation tokens
Both tokens are minted with random_bytes(32) and stamped with the time they
were created (reset_token_created / temp_token_created). Check a token's age
before acting on it:
// on the model $user->isResetTokenValid(); $user->isTempTokenValid(); // or look the user up by a token that has not expired $userRepository->withValidResetToken($token); $userRepository->withValidTempToken($token);
Tokens minted before these columns existed have no recorded age and are treated as expired, so outstanding links from before the migration stop working.
Basic example usage
Usage
<?php namespace controller; class authentication { public static function login(Request $request) { $login_form = new Form($request); $login_form->add_email('email', ['required' => true]); $login_form->add_password('password', ['required' => true]); $auth_failed = false; $is_logged_in = \Tnt\Account\Facade\Auth::isAuthenticated(); if ($login_form->validate()) { if ( \Tnt\Account\Facade\Auth::authenticate( $login_form->get('email'), $login_form->get('password') ) ) { $is_logged_in = true; } else { $auth_failed = true; } } $tpl = new Template(); $tpl->login_form = $login_form; $tpl->auth_failed = $auth_failed; $tpl->is_logged_in = $is_logged_in; $tpl->render('users/login.tpl'); } public static function register(Request $request) { $app = Application::get(); $register_form = new Form($request); $register_failed = false; $register_form->add_email('email', [ 'required' => true, 'extra_validation' => function ($value, &$errors) use ( &$register_failed, $app ) { if ( $app ->get(AuthenticationInterface::class) ->getActivatedUser($value) ) { $errors[] = 'user_already_activated'; $register_failed = true; } }, ]); $register_form->add_password('password', ['required' => true]); if ($register_form->validate()) { $user = $app ->get(AuthenticationInterface::class) ->register( $register_form->get('email'), $register_form->get('password') ); echo 'User registered ' . $user->email; } $tpl = new Template(); $tpl->register_form = $register_form; $tpl->register_failed = $register_failed; $tpl->render('users/register.tpl'); } public static function logout(Request $request) { \Tnt\Account\Facade\Auth::logout(); Response::redirect('login/'); } }