当前位置:网站首页>Tiktok practice ~ one click registration and login process of mobile phone number (verification code)
Tiktok practice ~ one click registration and login process of mobile phone number (verification code)
2022-06-22 09:46:00 【gblfy】


List of articles
One 、 One click registration login process

Two 、 front end
2.1. Verification code acquisition process
- 1. Click on -> Get the verification code call the back end to get the verification code api Interface
- 2. Verification Code 59 Second countdown
- 3. Click repeatedly to get the verification code , Judge whether the verification code countdown is greater than 0:
- 3.1. If it is greater than 0, The get verification code button is not touchable
- 3.2. If it is equal to 0, Get the verification code call the back end to get the verification code api Interface
2.2. Verification code acquisition code
var serverUrl = app.globalData.serverUrl;
// Call the back end to send the verification code
uni.request({
method: "POST",
url: serverUrl + "/passport/getSMSCode?mobile=" + mobile,
success(result) {
var status = result.data.status;
if (status != 200) {
uni.showToast({
title: result.data.msg,
icon: "none"
});
}
// Start counting down 60 Second limit
if(me.codeTimes == 0) {
me.doTimer(59);
}
}
});
},
// Countdown method for sending verification code
doTimer(times) {
var me = this;
// Countdown timer
var sendCodeBtnFunction = function(){
var left = times--;
if (left <= 0) {
me.codeTouched = false;
me.codeBtnText = " Send verification code ";
clearInterval(smsTimer);
} else {
me.codeBtnText = left + "s";
}
me.codeTimes = left;
};
var smsTimer = setInterval(sendCodeBtnFunction, 1000);
},
3、 ... and 、 Back end verification code
3.1. Preprocessing
In order to avoid invalid operations caused by frequent access to verification codes , therefore , The verification code acquisition logic needs to be pre intercepted .
According to the user ip Limit , Limit users to 60 You can only get the verification code once in seconds
Enter the first -> Verification code pre interception processing :
- 1. Get the user's ip
- 2. Verification Code redis Storage key The prefix of + Get the user's ip treat as redis Medium key, from redis Get the stored request in ip
- 1. If redis There are unexpired user requests in ip, Prompt " Text messages are sent too fast ~ Please try again later !"
- 2. If redis in , There are no user requests ip, The release , Continue to call the get verification code interface api

3.2. Interceptor add

3.3. Get verification code
- 1. Verify the data filled in the input box , Illegal tips , Legal continuation .
- 2. Get user requests ip
- 3. According to the user ip Limit , Limit users to 60 You can only get the verification code once in seconds
- 4. Generate random 6 Bit verification code
- 5. Call Tencent / Alibaba SMS service , Send verification code
- 6. Put the verification code into redis in , For subsequent verification
- 7. Return verification code

边栏推荐
- [学习笔记] 回滚莫队
- 如何将数据库中的值经过Servlet传到jsp页面通过EL表达式中显示出来?
- 【科普】一文弄懂监督式学习、非监督式学习以及强化式学习
- Binary String
- Network security Kali penetration learning how to conduct Nessus vulnerability detection
- Solutions to prompt non standard import in go language
- 全力以赴把防汛救灾措施落细落实落到位 坚决守护好人民群众生命财产安全
- Debian10 创建用户、用户组、切换用户
- SQL编程task03作业-复杂一点的查询
- 6-7 average the surrounding elements of a two-dimensional array
猜你喜欢
随机推荐
Logistic regression and linear regression
Network security Kali penetration learning how to conduct Nessus vulnerability detection
Brush questions in C language | output 6 decimal places with%f control character (17)
[node] scaffolding server to complete token verification
信息系统项目典型生命周期模型
C语言编写一个双向链表
软件工程 大题
rewrite? Reload? Are you dizzy?
Double machine hot standby of firewall on ENSP
搭建OpenPGP Key server
Debian10安装Zabbix5.4
PAT甲级 1016 Phone Bills(时间差)
Bloom filter optimization - crimsondb series of papers (I)
FileZilla server prompts 550 could not open file for reading when downloading files (illustration)
快速掌握 ASP.NET 身份认证框架 Identity - 登录与登出
Debian10 创建用户、用户组、切换用户
支付-订单案例构建
[node] theory + practice enables you to win sessions and cookies
APM 飞行模式切换--源码详解
IDE 的主题应该用亮色还是暗色?终极答案来了!









