當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。