Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 3 days 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 (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-11T06:35:37.000Z (5 months ago)
- Last Synced: 2024-10-10T13:09:10.603Z (4 months 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
[![Latest Version on Packagist](https://img.shields.io/packagist/v/infinitypaul/laravel-password-history-validation.svg?style=flat-square)](https://packagist.org/packages/infinitypaul/laravel-password-history-validation)
[![Build Status](https://img.shields.io/travis/infinitypaul/laravel-password-history-validation/master.svg?style=flat-square)](https://travis-ci.org/infinitypaul/laravel-password-history-validation)
[![Quality Score](https://img.shields.io/scrutinizer/g/infinitypaul/laravel-password-history-validation.svg?style=flat-square)](https://scrutinizer-ci.com/g/infinitypaul/laravel-password-history-validation)
[![Total Downloads](https://img.shields.io/packagist/dt/infinitypaul/laravel-password-history-validation.svg?style=flat-square)](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