https://github.com/infinitypaul/laravel-password-history-validation
Prevent users from reusing recently used passwords
https://github.com/infinitypaul/laravel-password-history-validation
laravel password password-history rules validation
Last synced: over 1 year ago
JSON representation
Prevent users from reusing recently used passwords
- Host: GitHub
- URL: https://github.com/infinitypaul/laravel-password-history-validation
- Owner: infinitypaul
- License: mit
- Created: 2020-03-11T11:59:11.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-11T06:35:37.000Z (almost 2 years ago)
- Last Synced: 2024-10-10T13:09:10.603Z (almost 2 years ago)
- Topics: laravel, password, password-history, rules, validation
- Language: PHP
- Homepage: https://medium.com/@infinitypaul
- Size: 41 KB
- Stars: 82
- Watchers: 2
- Forks: 27
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Password History Validation
[](https://packagist.org/packages/infinitypaul/laravel-password-history-validation)
[](https://travis-ci.org/infinitypaul/laravel-password-history-validation)
[](https://scrutinizer-ci.com/g/infinitypaul/laravel-password-history-validation)
[](https://packagist.org/packages/infinitypaul/laravel-password-history-validation)
Prevent users from reusing recently used passwords.
## Installation
You can install the package via composer:
```bash
composer require infinitypaul/laravel-password-history-validation
```
## Configuration
To get started, you'll need to publish the config file, and migrate the database:
```bash
php artisan vendor:publish --tag=password-config
```
Modify the config file according to your project, then migrate the database
```bash
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
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