Laravel – Prevent User to Enter Common Passwords

in this post, We will see you, how to prevent user to enter common password in laravel application.The laravel unicodeveloper/laravel-password package

This package can be used to verify the user provided password is not one of the top 10,000 worst passwords as analyzed by a respectable IT security analyst.

Pre-Requisite for this package :

  • PHP 5.5+ or HHVM 3.3+
  • Composer

This package help to prevent user to enter common password into login page, like “123456”, “123123”, “abcd” etc. So this type of ordinary password can be guess by other person and logged-in into your account. So, We will use this package for prevent this type of common password enter by user.

So, let’s follow below steps to integrate this plugin.We ll also display error message if anything wrong in user entered password :

I am assuming, You have laravel  application with registered page, We just let you know, How to integrate unicodeveloper/laravel-password package with laravel 7. if you are facing any issues, You can get more information from How To install Laravel 7 using composer.

Step 1 : Install unicodeveloper/laravel-password Application

Let’s install this package using below command, So open your terminal OR command prompt and run below command:

composer require unicodeveloper/laravel-password

if you’re on Laravel < 5.5, you’ll need to register the service provider. Open up config/app.php and add the following to the providers array:

Add Validation Message in Laravel 7

Let’s add custom message for package validation. So add below message into the resources/lang/en/validation.php file:

How To Apply Validation Rule in PHP

Let’s call validation rule into the controller file, open app/Http/Controllers/Auth/RegisterController.php file added below code into this file :

Now, We are ready to run our example using below artisan command :

php artisan serve

Let’s open below URL on your browser:

http://localhost:8000/

I hope it can help you.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.