Esempio n. 1
0
 def validate(self,attrs):
     tjw=TJW(settings.SECRET_KEY,300)
     try:
         data=tjs.loads(attrs["access_token"])
     except:
         raise serializers.ValidationError("无效的token")
     openid=data.get("openid")
     attrs["openid"]=openid
     real_sms_code=smscodeview.checksmscode(attrs["mobile"])
     if not real_sms_code:
         raise serializers.validationError("短信验证失效")
     if attrs["sms_code"]!=real_sms_code:
         raise serializers.validationerror("短信不一致")
     try:
         user=user.objects.get(mobile=attrs["mobile"])
     except:
         return attrs
     else:
         if not user.cjeck_password(attrs["password"]):
             raise serializers.validationerror("密码错误")
         attrs["user"]=user
         return attrs
Esempio n. 2
0
 def validate_like_num(self, like_num):
     if like_num != 0:
         raise serializers.ValidationError('不可以开挂偶')
     return like_num
Esempio n. 3
0
 def validate_no_like(self, no_like):
     print(no_like)
     if no_like != 0:
         raise serializers.ValidationError('不可以开挂偶')
     return no_like
Esempio n. 4
0
 def validate_nvum(self, nvum):
     if nvum != 0:
         raise serializers.ValidationError('不可以开挂偶')
     return nvum
Esempio n. 5
0
 def validate_is_hot(self, is_hot):
     if is_hot == 1 or is_hot == 0:
         return is_hot
     raise serializers.ValidationError('支支持一和0,1表示热点新闻,2表示不是热点新闻')
Esempio n. 6
0
 def validate_no_like(sel,no_like):
     if no_like != 0:
         raise serializers.ValidationError('别想作弊偶')
     return no_like