本文整理汇总了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
示例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)
示例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)