diff --git a/app/Http/Controllers/Shop/CustomerController.php b/app/Http/Controllers/Shop/CustomerController.php index 0afa00c3..52e4ffe8 100644 --- a/app/Http/Controllers/Shop/CustomerController.php +++ b/app/Http/Controllers/Shop/CustomerController.php @@ -168,8 +168,26 @@ class CustomerController extends Controller return __('Les mots de passe ne correspondent pas.'); } - if (strlen($request->input('new-password')) < 8) { - return __('Le nouveau mot de passe doit contenir au moins 8 caractères.'); + $newPassword = $request->input('new-password'); + + if (strlen($newPassword) < 8) { + return __('Le mot de passe doit contenir au moins 8 caractères.'); + } + + if (! preg_match('/[a-z]/', $newPassword)) { + return __('Le mot de passe doit contenir au moins une lettre minuscule.'); + } + + if (! preg_match('/[A-Z]/', $newPassword)) { + return __('Le mot de passe doit contenir au moins une lettre majuscule.'); + } + + if (! preg_match('/[0-9]/', $newPassword)) { + return __('Le mot de passe doit contenir au moins un chiffre.'); + } + + if (! preg_match('/[^A-Za-z0-9]/', $newPassword)) { + return __('Le mot de passe doit contenir au moins un caractère spécial.'); } $customer->password = Hash::make($request->input('new-password')); diff --git a/resources/views/Shop/auth/partials/password_rules.blade.php b/resources/views/Shop/auth/partials/password_rules.blade.php new file mode 100644 index 00000000..88f4ee0a --- /dev/null +++ b/resources/views/Shop/auth/partials/password_rules.blade.php @@ -0,0 +1,62 @@ +@php + $passwordInputId = $passwordInputId ?? 'password'; +@endphp + +
+ +@once +@push('css') + +@endpush + +@push('js') + +@endpush +@endonce diff --git a/resources/views/Shop/auth/partials/register.blade.php b/resources/views/Shop/auth/partials/register.blade.php index 1ddd50a3..57d72dc8 100644 --- a/resources/views/Shop/auth/partials/register.blade.php +++ b/resources/views/Shop/auth/partials/register.blade.php @@ -11,10 +11,12 @@ {{ Form::password('password', [ 'class' => 'form-control', + 'id' => 'password', 'placeholder' => __('boilerplate::auth.fields.password'), 'required', ]) }} {!! $errors->registration->first('password', ':message
') !!} + @include('Shop.auth.partials.password_rules', ['passwordInputId' => 'password'])