1. Go to this page and download the library: Download sicaboy/laravel-security library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Add rule instance to the field validation rules list
public function rules()
{
return [
'password_field' => [
' 'regex:/[A-Z]/', // must contain at least one uppercase letter
'regex:/[0-9]/', // must contain at least one digit
//...
new \Sicaboy\LaravelSecurity\Rules\NotCommonPassword(),
new \Sicaboy\LaravelSecurity\Rules\NotAUsedPassword($user),
],
];
}
// Also you need to call event, examples in the next section
// Call on user password change
event(new \Illuminate\Auth\Events\PasswordReset($user));
// If you are using custom login, register and reset password actions which are not the Laravel built-in ones, you will need to call event in your function accordingly.
event(new \Illuminate\Auth\Events\Login($user));
event(new \Illuminate\Auth\Events\Registered($user));
event(new \Illuminate\Auth\Events\PasswordReset($user));
...
'password_policy' => [
// Delete accounts with days of no activity
'auto_delete_inactive_accounts' => [
'enabled' => true,
...
],
// Lock out accounts with days of no activity
'auto_lockout_inactive_accounts' => [
'enabled' => true,
...
],
]
...