当前位置:网站首页>The number of password errors during login is too many, and the user is blocked,
The number of password errors during login is too many, and the user is blocked,
2022-07-28 06:14:00 【Ke Yulong】
This article describes an example when a user is 3 Password input error within minutes exceeds 5 Time , Block the current user 30 You cannot log in within minutes
async def get(self):
# Get the front-end parameters
email = self.get_argument("email",None)
password = self.get_argument("password",None)
# Get counter redis
number = self.application.redis.get("num_%s" % email)
try:
if self.application.redis.get("black_" + email):
return self.finish({"msg": " It has been banned. Try again later ", "errcode": 4})
# If there is redis
if number:
if int(number) > 4:
self.application.redis.setex("black_"+email,1800,1)
return self.finish({"msg": " It has been banned. Try again later ", "errcode": 5})
# Verify the account and password
user = await self.application.objects.get(UserModel.select().where((UserModel.email==email) & (UserModel.password == make_password(password))))
# Determine whether to activate
if user.srare ==0:
return self.finish({"msg":" Please activate this user ","errcode":2})
# write in token
myjwt = Myjwt()
token = myjwt.encode({"uid":user.id,"email":user.email})
return self.finish({"msg":" Login successful ","errcode":0,"email":user.email,"token":token})
except Exception as e:
if number:
self.application.redis.incr("num_%s"%email)
else:
self.application.redis.setex("num_%s"%email,180,1)
return self.finish({"msg":" Incorrect account or password ","errcode":3})

边栏推荐
- Applet development
- What about the app store on wechat?
- D2SC-GAN:基于双深浅通道生成对抗网络的课堂场景低分辨率人脸识别
- alpine,debian替换源
- Basic usage of word2vec and Bert
- uView上传组件upload上传auto-upload模式图片压缩
- Deep learning (self supervision: simple Siam) -- Exploring simple Siamese representation learning
- Reinforcement learning - incomplete observation problem, MCTs
- The signature of the update package is inconsistent with that of the installed app
- 自动定时备份远程mysql脚本
猜你喜欢

self-attention学习笔记

四、模型优化器与推理引擎

Improved knowledge distillation for training fast lr_fr for fast low resolution face recognition model training

Centos7 installing MySQL

Interviewer: let you design a set of image loading framework. How would you design it?

Pytorch deep learning single card training and multi card training

无约束低分辨率人脸识别综述三:同质低分辨率人脸识别方法

强化学习——价值学习中的DQN

神经网络学习

How to do wechat group purchase applet? How much does it usually cost?
随机推荐
一、AMD - OpenVINO环境配置
alpine,debian替换源
D2SC-GAN:基于双深浅通道生成对抗网络的课堂场景低分辨率人脸识别
NLP中常用的utils
利用辅助未标记数据增强无约束人脸识别《Boosting Unconstrained Face Recognition with Auxiliary Unlabeled Data》
Uniapp WebView listens to the callback after the page is loaded
Using neural network to predict the weather
三、OpenVINO实战:图像分类
matplotlib数据可视化
Reinforcement learning - Multi-Agent Reinforcement Learning
Kubesphere installation version problem
Alpine, Debian replacement source
Building neural network based on tensorflow
Model Inversion Attacks that Exploit Confidence Informati on and Basic Countermeasures 阅读心得
The business of digital collections is not so easy to do
Construction of redis master-slave architecture
Bert based data preprocessing in NLP
Paper reading notes of field low resolution face recognition based on selective knowledge extraction
word2vec和bert的基本使用方法
强化学习——价值学习中的DQN