当前位置:网站首页>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 .
边栏推荐
- 以VMware创新之道,重塑多云产品力
- From the perspective of technology and risk control, it is analyzed that wechat Alipay restricts the remote collection of personal collection code
- jxl笔记
- A specific example of ABAP type and EDM type mapping in SAP segw transaction code
- Why is your next computer a computer? Explore different remote operations
- LeetCode20.有效的括号
- 《信息系统项目管理师》备考笔记---信息化知识
- Taobao, pinduoduo, jd.com, Doudian order & Flag insertion remarks API solution
- 10 minute fitness method reading notes (2/5)
- 10 minute fitness method reading notes (5/5)
猜你喜欢

Didi open source Delta: AI developers can easily train natural language models

Tips and tricks of image segmentation summarized from 39 Kabul competitions

逆波兰表达式

无密码身份验证如何保障用户隐私安全?

上午面了个腾讯拿 38K 出来的,让我见识到了基础的天花

About LDA model

CF:A. The Third Three Number Problem【关于我是位运算垃圾这个事情】

你的下一台电脑何必是电脑,探索不一样的远程操作

946. Verify stack sequence

石臻臻的2021总结和2022展望 | 文末彩蛋
随机推荐
Install rhel8.2 virtual machine
Simply take stock reading notes (1/8)
stirring! 2022 open atom global open source summit registration is hot!
实战模拟│JWT 登录认证
RHCSA3
Transactions on December 23, 2021
10 minute fitness method reading notes (2/5)
太方便了,钉钉上就可完成代码发布审批啦!
Lepton 无损压缩原理及性能分析
DNS的原理介绍
10 minute fitness method reading notes (1/5)
#yyds干货盘点#js截取文件后缀名
How to connect the API interface of Taobao open platform (super detailed)
Setting up sqli lab environment
滴滴开源DELTA:AI开发者可轻松训练自然语言模型
What if wechat is mistakenly sealed? Explain the underlying logic of wechat seal in detail
CVPR 2022 | 基于稀疏 Transformer 的单步三维目标识别器
2021.12.16-2021.12.20 empty four hand transaction records
SAP SEGW 事物码里的 Association 建模方式
2021-12-22 transaction record