def confirm_validate_token(self, token, expiration=3600): # 序列化对象 serilizer = utsr(self.secret_key) try: res = serilizer.loads(token, salt=self.salt, max_age=expiration) except SignatureExpired: #token过期 return -1 except BadSignature: return -2 except: return -3 return res
def confirm_validate_token(self, token, expiration=3600): ''' 只要令牌没过期,那它就会返回一个用户名,过期时间为3600秒。 ''' serializer = utsr(self.security_key) return serializer.loads(token, salt=self.salt, max_age=expiration)
def generate_validate_token(self, user_name): serializer = utsr(self.security_key) return serializer.dumps(user_name, self.salt)
def confirm_validate_token(self, token, expiration=3600): serializer = utsr(self.security_key) # max_age,时间限制,在max_age之前的秒不能用,即3600=60*60,则有效时间为一个小时 return serializer.loads(token, salt=self.salt, max_age=expiration)
def confirm_validate_token(self,token,expiration=3600): serializer = utsr(self.security_key) return serializer.loads(token, salt=self.salt, max_age=expiration)
def remove_validate_token(self, token): serializer = utsr(self.security_key) print(serializer.loads(token, salt=self.salt)) return serializer.loads(token, salt=self.salt)
def confirm_token(cls, token, expiration=3600): try: serializer = utsr(cls.security_key) return serializer.loads(token, salt=cls.salt, max_age=expiration) except Exception, e: return ''
def generate_validate_token(self, username): serializer = utsr(self.security_key) timeStamp = TimestampSigner(self.security_key) username = timeStamp.sign(username) return serializer.dumps(username, self.salt)
def generate_validate_token(self,uid): #序列化对象 serilizer = utsr(self.secret_key) #返回token值 return serilizer.dumps(uid,self.salt)
def generate_validate_token(cls, data): serializer = utsr(cls.security_key) return serializer.dumps(data, cls.salt)
def generate_validate_token(self, username): serializer = utsr(self.security_key) # convert the serializer to the json form return serializer.dumps(username, self.salt)
def confirm_validate_token(self, token, expiration=settings.TOKEN_EXPIRATION): #验证口令的函数 serializer = utsr(self.security_key) return serializer.loads(token, salt=self.salt, max_age=expiration)
def generate_validate_token(self, email): serializer = utsr(self.security_key) return serializer.dumps(email, self.salt)
def confirm_validate_token(token, expiration=settings.SMALL_WEIXIN_TOKEN_VALID_TIME): serializer = utsr(settings.SECRET_KEY) salt = base64.encodestring(settings.SECRET_KEY) return serializer.loads(token, salt=salt, max_age=expiration)
def remove_validate_token(self, token): serializer = utsr(self.security_key) timeStamp = TimestampSigner(self.security_key) username = serializer.loads(token, salt=self.salt) username = timeStamp.unsign(username) return username
def generate_validate_token(openid): serializer = utsr(settings.SECRET_KEY) salt = base64.encodestring(settings.SECRET_KEY) return serializer.dumps(openid, salt)
def confirm_validate_token(self,token,expiration=3600*24): serializer = utsr(self.security_key) return serializer.loads(token, salt=self.salt, max_age=expiration)
def confirm_validate_token(self, token): serializer = utsr(self.security_key) return serializer.loads( token, salt=self.salt, )
def generate_validate_token(self, useremail): # 生成令牌环 serializer = utsr(self.security_key) return serializer.dumps(useremail, self.salt) # 转换为json格式化数据
def generate_validate_token(self, username): serializer = utsr(self.security_key) return serializer.dumps(username, self.salt)
def remove_validate_token(self, token): serializer = utsr(self.secret_key) return serializer.loads(token, salt=self.salt)