當前位置: 首頁>>代碼示例>>Python>>正文


Python Secret.lookup_secret方法代碼示例

本文整理匯總了Python中community_share.models.secret.Secret.lookup_secret方法的典型用法代碼示例。如果您正苦於以下問題:Python Secret.lookup_secret方法的具體用法?Python Secret.lookup_secret怎麽用?Python Secret.lookup_secret使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在community_share.models.secret.Secret的用法示例。


在下文中一共展示了Secret.lookup_secret方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: from_api_key

# 需要導入模塊: from community_share.models.secret import Secret [as 別名]
# 或者: from community_share.models.secret.Secret import lookup_secret [as 別名]
 def from_api_key(self, key):
     secret = Secret.lookup_secret(key)
     logger.debug('key is {0}'.format(key))
     logger.debug('secret is {0}'.format(secret))
     user_id = None
     if secret is not None:
         info = secret.get_info()
         if info.get('action', None) == 'api_key':
             user_id = info.get('userId', None)
     if user_id is not None:
         user = store.session.query(User).filter_by(id=user_id).first()
         logger.debug('user from api_key is {0}'.format(user))
     else:
         user = None
     return user
開發者ID:seanastephens,項目名稱:communityshare,代碼行數:17,代碼來源:user.py

示例2: process_password_reset

# 需要導入模塊: from community_share.models.secret import Secret [as 別名]
# 或者: from community_share.models.secret.Secret import lookup_secret [as 別名]
def process_password_reset(secret_key, new_password):
    user = None
    error_messages = User.is_password_valid(new_password)
    if not error_messages:
        secret = Secret.lookup_secret(secret_key)
        error_message = ''
        if secret is not None:
            secret_info = secret.get_info()
            userId = secret_info.get('userId', None)
            action = secret_info.get('action', None)
            if action == 'password_reset' and userId is not None:
                user = store.session.query(User).filter_by(id=userId).first()
                if user is not None:
                    error_messages += user.set_password(new_password)
                    if not error_messages:
                        secret.used = True
                        store.session.add(user)
                        store.session.add(secret)
                        store.session.commit()
        else:
            error_messages.append('Authorization for this action is invalid or expired.')
    return (user, error_messages)
開發者ID:TimmyTomTom,項目名稱:commshare,代碼行數:24,代碼來源:mail_actions.py

示例3: process_confirm_email

# 需要導入模塊: from community_share.models.secret import Secret [as 別名]
# 或者: from community_share.models.secret.Secret import lookup_secret [as 別名]
def process_confirm_email(secret_key):
    error_messages = []
    user = None
    secret = Secret.lookup_secret(secret_key)
    if secret is not None:
        secret_info = secret.get_info()
        userId = secret_info.get('userId', None)
        action = secret_info.get('action', None)
        if action == 'email_confirmation' and userId is not None:
            user = store.session.query(User).filter_by(id=userId).first()
            if user is not None:
                user.email_confirmed = True
                secret.used = True
                store.session.add(user)
                store.session.add(secret)
                store.session.commit()
            else:
                error_messages.append('Authorization is for an unknown user.')
        else:
            error_mesage('Authorization is not valid for this action.')
    else:
        error_messages.append('Authorization for this action is invalid or expired.')
    return (user, error_messages)
開發者ID:TimmyTomTom,項目名稱:commshare,代碼行數:25,代碼來源:mail_actions.py


注:本文中的community_share.models.secret.Secret.lookup_secret方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。