def validate_verifycode(self, field): mobile = self.mobile.data code = mc.get(mobile) #从memcached中取出这个手机号码对应的验证码 print(code) print(type(code)) if not code or code != field.data: raise ValidationError(message='手机验证码错误')
def validate_code(self, field): mobile = g.front_user.telephone code = mc.get(mobile) # 从memcached中取出这个手机号码对应的验证码 print(code) print(type(code)) if not code or code != field.data: raise ValidationError(message='手机验证码错误')
def sendcode(): ''' :param mobile :return: (1): code:412 手机号码输入不正确,或者已被注册 (2): code:200 发送短信成功 ''' form=Verify_sendcode(request.form) #验证表单 if form.validate(): mobble=form.mobile.data code=random.randrange(1000,9999) code=str(code) print(code) smsContent='【爱家社区】您的验证码为{0},请于5分钟内正确输入,如非本人操作,请忽略此短信。'.format(code) sendIndustrySms(mobble,smsContent) mc.set(mobble,code,300) #把短信验证码存放在memcached里面 print(mc.get(mobble)) return jsonify({'code':200,'message':'发送成功'}) else: message = form.errors.popitem()[1][0] #弹出第一条验证失败错误信息 print(type(jsonify({'code':406}))) return jsonify({'code':412,'message':message})
def validate_img_code(self, field): img_code = field.data.lower() code = mc.get(img_code) if not code or code != img_code: raise ValidationError('验证码不正确')
def validate_imgverifycode(self, field): data = field.data.lower() code = mc.get(data) #从图片中取出验证码 if not code or code != data: raise ValidationError('图片验证码错误')
def validate_email_code(self, field): #如果用户名和密码都满足 code = mc.get(self.email.data) #从memcached中取用户名为email值得这个数 if not code or field.data != code: #判断用户输入的邮箱号和验证码是否和先前获取的存放在mecached里面的一样,判断是否取得到 raise ValidationError('邮箱或者验证码错误')
def validate_img_code(self, field): img_code = field.data user_id = g.front_user.id code = mc.get(user_id) if not code and img_code != code: raise ValidationError(message='验证码输入不正确')
def validate_code(self, field): #验证验证码是否正确 mobile = self.mobile.data if mobile != None: code = mc.get(mobile) if not code or code != field.data: raise ValidationError(message='验证码错误')