当前位置:网站首页>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-fileinfo
Then generate the corresponding config file :
php artisan vendor:publish
Enter 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 CaptchaValidationController
stay 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 .
边栏推荐
- Distance measuring sensor chip 4530a used in home intelligent lighting
- From the perspective of technology and risk control, it is analyzed that wechat Alipay restricts the remote collection of personal collection code
- HiEngine:可媲美本地的云原生内存数据库引擎
- Docker configures redis and redis clusters
- 《信息系统项目管理师》备考笔记---信息化知识
- Iterator details in list... Interview pits
- What is the difference between Bi software in the domestic market
- Yyds dry inventory JS intercept file suffix
- [cloud native] use of Nacos taskmanager task management
- insmod 提示 Invalid module format
猜你喜欢
国内市场上的BI软件,到底有啥区别
研究:数据安全工具在 60% 的情况下无法抵御勒索软件
Introduction aux contrôles de la page dynamique SAP ui5
Oppo Xiaobu launched Obert, a large pre training model, and promoted to the top of kgclue
Introduction to the principle of DNS
ABAP editor in SAP segw transaction code
Alipay transfer system background or API interface to avoid pitfalls
初识Linkerd项目
CVPR 2022 | 基于稀疏 Transformer 的单步三维目标识别器
将函数放在模块中
随机推荐
How can non-technical departments participate in Devops?
What if wechat is mistakenly sealed? Explain the underlying logic of wechat seal in detail
Halcon template matching actual code (I)
2021-12-21 transaction record
【Nacos云原生】阅读源码第一步,本地启动Nacos
跨平台(32bit和64bit)的 printf 格式符 %lld 输出64位的解决方式
Transactions from January 14 to 19, 2022
Laravel文档阅读笔记-mews/captcha的使用(验证码功能)
SAP SEGW 事物码里的导航属性(Navigation Property) 和 EntitySet 使用方法
MySQL 巨坑:update 更新慎用影响行数做判断!!!
Volatile instruction rearrangement and why instruction rearrangement is prohibited
Didi open source Delta: AI developers can easily train natural language models
##无监控,不运维,以下是监控里常用的脚本监控
Talk about my drawing skills in my writing career
Transactions from January 6 to October 2022
SAP UI5 视图里的 OverflowToolbar 控件
HiEngine:可媲美本地的云原生内存数据库引擎
10 minute fitness method reading notes (3/5)
Why is your next computer a computer? Explore different remote operations
SAP self-development records user login logs and other information