Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrysanthos/password-history
Keep history of users' hashed passwords so users don't reuse them
https://github.com/chrysanthos/password-history
hacktoberfest laravel password-history
Last synced: 18 days ago
JSON representation
Keep history of users' hashed passwords so users don't reuse them
- Host: GitHub
- URL: https://github.com/chrysanthos/password-history
- Owner: chrysanthos
- License: mit
- Created: 2020-01-13T17:37:44.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-15T18:59:58.000Z (almost 2 years ago)
- Last Synced: 2024-10-09T16:48:26.458Z (30 days ago)
- Topics: hacktoberfest, laravel, password-history
- Language: PHP
- Homepage:
- Size: 25.4 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Password history for Laravel
[![Latest Version on Packagist](https://img.shields.io/packagist/v/Chrysanthos/password-history.svg?style=flat-square)](https://packagist.org/packages/chrysanthos/password-history)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/chrysanthos/password-history/run-tests.yml?branch=master&label=tests)](https://github.com/chrysanthos/password-history/actions?query=workflow%3Arun-tests+branch%3Amaster)
[![Total Downloads](https://img.shields.io/packagist/dt/chrysanthos/password-history.svg?style=flat-square)](https://packagist.org/packages/chrysanthos/password-history)The Laravel package maintains encrypted user password history so that you can prevent users from using a previously used password.
## Installation
You can install the package via composer:
```bash
composer require chrysanthos/password-history
```## Usage
The package service provider is registered automatically and a migration is provided to be run.
Run your migrations
``` bash
php artisan migrate
```In your `App\Http\Controllers\Auth\ResetPasswordController` override Laravel's default `rules` method with the following
```php
use Chrysanthos\PasswordHistory\Rules\NoOldPasswords;/**
* Get the password reset validation rules.
*
* @return array
*/
protected function rules()
{
return [
'token' => 'required',
'email' => 'required|email',
'password' => [
'required', 'confirmed', 'min:8',
new NoOldPasswords(User::whereEmail(request('email'))->first()->id, request('password'))
],
];
}
```Note: In case you changed the default Laravel auth `ResetPasswordController` you will need to dispatch the `PasswordReset` event that Laravel includes out of the box.
```php
use Illuminate\Auth\Events\PasswordReset;event(new PasswordReset($user));
```
### Testing``` bash
composer test
```### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please send me a message on twitter (@chrysanthos_cy) instead of using the issue tracker.
## Credits
- [Chrysanthos Prodromou](https://github.com/chrysanthos)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.