当前位置:网站首页>Laravel document reading notes -mews/captcha use (verification code function)
Laravel document reading notes -mews/captcha use (verification code function)
2022-07-05 12:58:00 【IT1995】
It's used here Laravel8.
The verification code here should be used to fileInfo The function of , Need to give in advance php Load this dll or so, stay php.ini Revision in China :

The final effect of the verification code function is :

First, add related libraries :
composer require mews/captcha --ignore-platform-req=ext-fileinfoThen generate the corresponding config file :
php artisan vendor:publishEnter your side mews/captcha Related options :

Here are the options 11.
The default verification code is 9 position , There's too much here , Can't see , Modify the captcha.php
<?php
return [
'characters' => ['2', '3', '4', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'm', 'n', 'p', 'q', 'r', 't', 'u', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'M', 'N', 'P', 'Q', 'R', 'T', 'U', 'X', 'Y', 'Z'],
'default' => [
'length' => 5,
'width' => 120,
'height' => 36,
'quality' => 90,
'math' => false,
'expire' => 60,
'encrypt' => false,
],
......
......
];here default.length The size of was originally 9 Of , I changed it to 5.
Generate corresponding Controller
php artisan make:controller CaptchaValidationControllerstay CaptchaValidationController.php Generate verification code in :
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class CaptchaValidationController extends Controller
{
public function reloadCaptcha()
{
return response()->json(['captcha'=> captcha_img()]);
}
}Here it is. Controller It's the verification code service . It's done. .
Here's how to use .
front end :
JS relevant :
<script type="text/javascript">
$('#captchaImg').click(function(){
$(this).prop('src',"{
{captcha_src()}}" + Math.random(1000,9999));
});
</script>HTML relevant :
<div class="row">
<div class="col" style="max-width: 140px">
<img src="{
{ captcha_src() }}" id="captchaImg" >
</div>
<div class="col pull-left ">
<input type="text" autocomplete="off" placeholder=" Verification Code " id="captcha" class="form-control" name="captcha">
</div>
</div>Back end :
public function customLogin(Request $request)
{
$request->validate([
'email' => 'required|email',
'password' => 'required|min:6|max:128',
'captcha' => 'required|captcha'
]);
......
......
}here Laravel I handled it myself , We just add captcha, That's all right. . I feel that there is a lot less logic judgment code than other languages .
边栏推荐
- Simply take stock reading notes (2/8)
- Taobao order amount check error, avoid capital loss API
- Setting up sqli lab environment
- SAP UI5 DynamicPage 控件介紹
- 10 minute fitness method reading notes (5/5)
- mysql拆分字符串做条件查询
- Neural network of PRML reading notes (1)
- 开发者,云原生数据库是未来吗?
- Time conversion error
- Why is your next computer a computer? Explore different remote operations
猜你喜欢

Kotlin variable

Taobao short videos are automatically released in batches without manual RPA open source

Concurrent performance test of SAP Spartacus with JMeter

A few years ago, I outsourced for four years. Qiu Zhao felt that life was like this

I met Tencent in the morning and took out 38K, which showed me the basic smallpox

Taobao order amount check error, avoid capital loss API

SAP UI5 DynamicPage 控件介绍

CVPR 2022 | single step 3D target recognizer based on sparse transformer

深度长文探讨Join运算的简化和提速

MySQL 巨坑:update 更新慎用影响行数做判断!!!
随机推荐
Principle and performance analysis of lepton lossless compression
SAP UI5 ObjectPageLayout 控件使用方法分享
JXL notes
Taobao order amount check error, avoid capital loss API
leetcode:221. 最大正方形【dp状态转移的精髓】
Compilation principle reading notes (1/12)
ActiveMQ installation and deployment simple configuration (personal test)
上午面了个腾讯拿 38K 出来的,让我见识到了基础的天花
Simply take stock reading notes (3/8)
Volatile instruction rearrangement and why instruction rearrangement is prohibited
SAP SEGW 事物码里的 ABAP 类型和 EDM 类型映射的一个具体例子
Reshape the power of multi cloud products with VMware innovation
Setting up sqli lab environment
自然语言处理系列(一)入门概述
超高效!Swagger-Yapi的秘密
Kotlin process control and circulation
jxl笔记
I'm doing open source in Didi
百日完成国产数据库opengausss的开源任务--openGuass极简版3.0.0安装教程
激动人心!2022开放原子全球开源峰会报名火热开启!