Hello Artisan
In this brand new tutorial i will show you how we can create strong password validation before registration in laravel. In this password validation example we will force user to give password must be more than 8 characters long, should contain at-least 1 Uppercase, 1 Lowercase, 1 Numeric and 1 special character before submit the form.
This is is going to be a very simple tutorial on how to use regex validation to make your password strength requirement stronger for a better security. We don't use any package to make strong password. We will use regex validation to make your password strength requirement stronger.
With regex strong password laravel we will also check password strength validation in laravel. Now you can see the preview of password validation in laravel of this tutorial.
Preview
Step 1 : Download Laravel
In this step, we need to download to create strong password validation for laravel application. Download it.
composer create-project --prefer-dist laravel/laravel test
Step 2 : Create Route
Open your routes/web.php and paste the following code.
routes/web.php
use Illuminate\Http\Request;
Route::get('/', function () {
return view('welcome');
})->name('test');
Route::post('/', function (Request $request) {
$request->validate([
'name' => 'required', 'string', 'max:255',
'email' => 'required', 'string', 'email', 'max:255', 'unique:users',
'password' => 'required|string|min:6|confirmed|regex:/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{6,}$/',
]);
return redirect()->back();
});
Step 3 : Create Register File
In this step we need to create our blade file to create regex strong password laravel. So create welcome file.
resources/views/welcome.blade.php
Read also : Forcing User to Prevent Common Password in Laravel
Hope it can help you to create strong password in your application.
#laravel #laravel-6 #laravel-7 #laravel-7x #prevent-common-password