当前位置: 首页>>代码示例>>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;未经允许,请勿转载。