Home>Article>PHP Framework> Teach you how to easily implement password strength verification in Laravel!
This article brings you relevant knowledge about Laravel. It mainly talks about how to implement password strength verification in Laravel? Friends who are interested can take a look below. I hope it will be helpful to everyone.
laravel password strength verification
Requirements
I hope the laravel framework allows users to enter Password strength can be conveniently specified when using the password
Includes:
It can be verified either mixedly or individually.
Official website: https://packagist.org/packages/schuppo/password-strength
Implementation:
1. Execute composer Install Laravel 6 and above according to the following schemeLaravel 5 according to the following schemecomposer require schuppo/password-strength:"~2.0"
2. Copy the language file Copy the following 4 lines Go to your own corresponding validation.php in resources/langcomposer require schuppo/password-strength:"~1.5"
3. Usage method In the following code, the password that the user is required to enter must be at least 6 digits and contain at least one lowercase letter. and contain at least one uppercase letter and at least one number."letters" => ":attribute 必须包含至少一个字母。",
"case_diff" => ":attribute 必须包含大小写字母。",
"numbers" => ":attribute 必须包含至少一个数字。",
"symbols" => ":attribute 必须包含至少一个符号。",
public function post(Request $request){
$validator = Validator::make($request->all(), [
'name'=>'bail',
'password'=>['bail','required','min:6','case_diff','numbers']
]);
if ($validator->fails()) {
return $validator->errors()->first();
}
return '正确';}
Summary
It smells so good! Recommended learning: "laravel video tutorial"
The above is the detailed content of Teach you how to easily implement password strength verification in Laravel!. For more information, please follow other related articles on the PHP Chinese website!