Strong Password Regex Validation with Laravel Authentication
This is a simple tutorial on how to use regex validation to make your password strength requirement stronger for better security.
We will implement Strong Password Regex Validation with Laravel Authentication.
Before we proceed further, make sure you have the following ready.
Password Validation Modification at User Registration.
Open RegisterController.php
which is located at App > Http > Controllers > Auth Directory. Under the validator()
method. Modify the password validation rule to add the regex rule as well.
We have added the following regex to the password validation.
This means the following
- Should have At least one uppercase letter.
- At least one Lower case letter.
- Also, At least one numeric value.
- And, At least one special character.
- Must be more than 6 characters long.
Open your register.blade.php
file which is located at resources > views > auth directory and add the following help block just below the password input field.
Password Validation Modification at Reset Password
Open ResetPasswordController.php
which is located at App > Http > Controllers > Auth Directory. Add the rules() method with following validation rules.
The rules()
method is available in <code>ResetPassword</code> trait. When we put in this controller, it overrides the default validation rules of Reset Password.
Next, Open your reset.blade.php
file which is located at resources > views > auth > passwords directory and add the following help block just below the password input field.
That's it! You now have a stronger password validation on top of Laravel Authentication.
0 Comments
CAN FEEDBACK
Emoji