lucaterribili / laravel-password-history-validation
Prevent users from reusing recently used passwords
Requires
- illuminate/console: 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || 6.* || 7.* || 8.* || 9.*
- illuminate/support: 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || 6.* || 7.* || 8.* || 9.*
Requires (Dev)
- phpunit/phpunit: 8.* || 9.*
This package is auto-updated.
Last update: 2024-10-25 18:46:15 UTC
README
Prevent users from reusing recently used passwords.
Installation
You can install the package via composer:
composer require lucaterribili/laravel-password-history-validation
Configuration
To get started, you'll need to publish the config file, and migrate the database:
php artisan vendor:publish --tag=password-config
Modify the config file according to your project, then migrate the database
php artisan migrate
Usage
This package will observe the created and updated event of the models (check the config file for settings) and records the password hashes automatically.
In Your Form Request or Inline Validation, All You Need To Do Is Instantiate The NotFromPasswordHistory
class passing the current user as an argument
<?php use LucaTerribili\LaravelPasswordHistoryValidation\Rules\NotFromPasswordHistory; $this->validate($request, [ 'password' => [ 'required', new NotFromPasswordHistory($request->user()) ] ]);
Cleaning Up Old Record - (Optional)
Because We Are Storing The Hashed Password In Your Database, Your Database Can Get Long When You Have Lots Of Users
Add PasswordHistoryTrait To Your User Model
<?php use LucaTerribili\LaravelPasswordHistoryValidation\Traits\PasswordHistoryTrait; class User extends Authenticatable { use Notifiable, PasswordHistoryTrait; }
Then You Can Run The Following Artisan Command
php artisan password-history:clear
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email dottorlucaterribili@gmail.com instead of using the issue tracker.
How can I thank you?
Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word!
Don't forget to follow me on Linkedin!
Thanks! Luca Terribili.
License
The MIT License (MIT). Please see License File for more information.