当前位置: 首页>>代码示例>>Python>>正文


Python itsdangerous.TimedJSONWebSignatureSerializer方法代码示例

本文整理汇总了Python中itsdangerous.TimedJSONWebSignatureSerializer方法的典型用法代码示例。如果您正苦于以下问题:Python itsdangerous.TimedJSONWebSignatureSerializer方法的具体用法?Python itsdangerous.TimedJSONWebSignatureSerializer怎么用?Python itsdangerous.TimedJSONWebSignatureSerializer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在itsdangerous的用法示例。


在下文中一共展示了itsdangerous.TimedJSONWebSignatureSerializer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: unsubscribe_user

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def unsubscribe_user(token):
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            data = s.loads(token)
        except:
            return None, None
        id = data.get('talk')
        email = data.get('email')
        if not id or not email:
            return None, None
        talk = Talk.query.get(id)
        if not talk:
            return None, None
        Comment.query\
            .filter_by(talk=talk).filter_by(author_email=email)\
            .update({'notify': False})
        db.session.commit()
        return talk, email 
开发者ID:miguelgrinberg,项目名称:flask-pycon2014,代码行数:20,代码来源:models.py

示例2: change_email

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def change_email(self, token):
        """Verify the new email for this user."""
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            data = s.loads(token)
        except (BadSignature, SignatureExpired):
            return False
        if data.get('change_email') != self.id:
            return False
        new_email = data.get('new_email')
        if new_email is None:
            return False
        if self.query.filter_by(email=new_email).first() is not None:
            return False
        self.email = new_email
        db.session.add(self)
        db.session.commit()
        return True 
开发者ID:gita,项目名称:BhagavadGita,代码行数:20,代码来源:user.py

示例3: verify_auth_token

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def verify_auth_token(token):
        """Validate the token whether is night."""

        serializer = Serializer(
            current_app.config['SECRET_KEY'])
        try:
            # serializer object already has tokens in itself and wait for
            # compare with token from HTTP Request /api/posts Method `POST`.
            data = serializer.loads(token)
        except SignatureExpired:
            return None
        except BadSignature:
            return None

        user = User.query.filter_by(id=data['id']).first()
        return user 
开发者ID:JmilkFan,项目名称:JmilkFan-s-Blog,代码行数:18,代码来源:models.py

示例4: get_reset_token

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def get_reset_token(self, expires_sec=300):
        s = Serializer(current_app.config["SECRET_KEY"], expires_sec)
        return s.dumps({"user_id": self.id}).decode("utf-8") 
开发者ID:pxsocs,项目名称:thewarden,代码行数:5,代码来源:models.py

示例5: verify_reset_token

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def verify_reset_token(token):
        s = Serializer(current_app.config["SECRET_KEY"])
        try:
            user_id = s.loads(token)["user_id"]
        except (KeyError, TypeError):
            return None
        return User.query.get(user_id) 
开发者ID:pxsocs,项目名称:thewarden,代码行数:9,代码来源:models.py

示例6: generate_confirmation_token

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def generate_confirmation_token(self, expiration=3600):
        s = Serializer(current_app.config['SECRET_KEY'], expiration)
        return s.dumps({'confirm': self.id}) 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:5,代码来源:models.py

示例7: confirm

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def confirm(self, token):
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            data = s.loads(token)
        except:
            return False
        if data.get('confirm') != self.id:
            return False
        self.confirmed = True
        db.session.add(self)
        return True 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:13,代码来源:models.py

示例8: generate_reset_token

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def generate_reset_token(self, expiration=3600):
        s = Serializer(current_app.config['SECRET_KEY'], expiration)
        return s.dumps({'reset': self.id}) 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:5,代码来源:models.py

示例9: reset_password

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def reset_password(self, token, new_password):
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            data = s.loads(token)
        except:
            return False
        if data.get('reset') != self.id:
            return False
        self.password = new_password
        db.session.add(self)
        return True 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:13,代码来源:models.py

示例10: generate_email_change_token

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def generate_email_change_token(self, new_email, expiration=3600):
        s = Serializer(current_app.config['SECRET_KEY'], expiration)
        return s.dumps({'change_email': self.id, 'new_email': new_email}) 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:5,代码来源:models.py

示例11: generate_auth_token

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def generate_auth_token(self, expiration):
        s = Serializer(current_app.config['SECRET_KEY'],
                       expires_in=expiration)
        return s.dumps({'id': self.id}).decode('ascii') 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:6,代码来源:models.py

示例12: verify_auth_token

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def verify_auth_token(token):
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            data = s.loads(token)
        except:
            return None
        return User.query.get(data['id']) 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:9,代码来源:models.py

示例13: generate_auth_token

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def generate_auth_token(self, expiration):
        s = Serializer(current_app.config['ECRET_KEY'],expires_in=expiration)
        return s.dumps({'id': self.id}) 
开发者ID:Blackyukun,项目名称:Simpleblog,代码行数:5,代码来源:models.py

示例14: verify_auth_token

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def verify_auth_token(token):
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            data = s.loads(token)
        except:
            return None
        return User.query.get(data['id'])

    # 把用户转换成JSON格式的序列化字典
    # 提供给客户端的内容无需和数据库模型内部完全一致 
开发者ID:Blackyukun,项目名称:Simpleblog,代码行数:12,代码来源:models.py

示例15: generate_auth_token

# 需要导入模块: import itsdangerous [as 别名]
# 或者: from itsdangerous import TimedJSONWebSignatureSerializer [as 别名]
def generate_auth_token(self, expires_in=3600):
        s = Serializer(current_app.config['SECRET_KEY'], expires_in=expires_in)
        return s.dumps({'id': self.id}).decode('utf-8') 
开发者ID:miguelgrinberg,项目名称:api-pycon2014,代码行数:5,代码来源:models.py


注:本文中的itsdangerous.TimedJSONWebSignatureSerializer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。