Implemented password validation rules in the AppServiceProvider class. Ensured passwords should be at least 8 characters long, contain a mix of uppercase, lowercase, and special characters. These rules apply only for the production environment.

This commit is contained in:
Leonid Nikitin 2023-07-02 15:21:01 +06:00
parent 719d4c7f10
commit 0073dffc28
Signed by: kor-elf
GPG Key ID: 7DE8F80C5CEC2C0D

View File

@ -13,6 +13,7 @@ use App\Captcha\Images\Lines;
use App\Services\Api\V1\CaptchaService;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Rules\Password;
final class AppServiceProvider extends ServiceProvider
{
@ -42,6 +43,16 @@ final class AppServiceProvider extends ServiceProvider
*/
public function boot(): void
{
//
Password::defaults(function () {
$rule = Password::min(8);
return $this->app->isProduction()
? $rule->letters()
->mixedCase()
->numbers()
->symbols()
->uncompromised()
: $rule;
});
}
}