imanghafoori/laravel-password-history
Pros:
saved event) to track password changes.config/password_history.php.Cons:
password_histories table (schema provided in migrations).users, password_resets).users table has password field (default) or configure custom field in config/password_history.php.composer require imanghafoori/laravel-password-history
php artisan vendor:publish --provider="Imanghafoori\PasswordHistory\PasswordHistoryServiceProvider"
php artisan migrate
config/password_history.php:
max_history (e.g., 5).protected models (e.g., App\Models\User).password_column if non-standard (e.g., encrypted_password).spatie/laravel-permission) if they also use model observers.AppServiceProvider or use explicit observer priorities.use Imanghafoori\PasswordHistory\Facades\PasswordHistory;
public function update(Request $request) {
$history = PasswordHistory::getHistory($request->user());
if (in_array($request->password, $history)) {
throw ValidationException::withMessages(['password' => 'This password was used before.']);
}
}
max_history (e.g., 20+), consider:
user_id and password columns in password_histories.max_history=5, expect ~100MB of storage.user_id or created_at.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Package update breaks Laravel | History tracking fails silently. | Pin version in composer.json (e.g., ^1.0). |
| Database migration fails | History table not created. | Rollback-safe migrations; test in staging. |
| Observer not triggered | Password changes unlogged. | Add logging to observer; monitor event queue. |
| Concurrent password updates | Duplicate/missing history entries. | Use Laravel’s queue:work for event processing. |
| Storage exhaustion | DB grows uncontrollably. | Set max_history and implement cleanup jobs. |
README.md, config/password_history.php, and `PasswordHistoryServiceProviderHow can I help you explore Laravel packages today?