drewlabs/passwords
最新稳定版本:v0.2.20
Composer 安装命令:
composer require drewlabs/passwords
包简介
Password resets implementation for drewlabs auth library
README 文档
README
Password reset is a workflow that allow application users to modify their connection credential a.k.a password while not being connected to the application.
drewlabs/passwords is a framework agnostic password reset workflow for PHP programming language, that support link based and otp based password reset.
Usage
The library ships with command classes for creating password reset link/otp a.k.a One Time Password, and other commands to validated the generated token or otp.
- Request password reset
use Drewlabs\Passwords\Commands\CreatePasswordResetCommand; use Drewlabs\Passwords\PasswordResetTokenRepository; use Drewlabs\Passwords\UrlFactory; use Drewlabs\Passwords\Contracts\TokenInterface; use Drewlabs\Passwords\Contracts\CanResetPassword; $repository = new PasswordResetTokenRepository(new Connection('sqlite:memory', 'password_resets')); $command = new CreatePasswordResetCommand($repository, new CanResetPasswordProvider, 'MySecret'); // Create a password reset link $command->handle('user@example.com', function(CanResetPassword $user, TokenInterface $token) { // TODOL: the command is completed, generate the password reset link }); //
Note In the code above the CanResetPasswordProvider is a fake user resolver implementation. Library users must provide their own user resolver that implement Drewlabs\Passwords\Contracts\CanResetPasswordProvider contract.
- Generate password reset OTP
Documentation is under development, any API changes or feature will be added accordingly.
- Passsword reset token repository
The drewlabs/passwords library ship a reset tokens repository implementation that is extensible by creating drivers that implements Drewlabs\Passwords\Contracts\ConnectionInterface contract.
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-26