本文整理匯總了Python中indico.modules.auth.Identity.find_all方法的典型用法代碼示例。如果您正苦於以下問題:Python Identity.find_all方法的具體用法?Python Identity.find_all怎麽用?Python Identity.find_all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類indico.modules.auth.Identity
的用法示例。
在下文中一共展示了Identity.find_all方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_user_from_identifier
# 需要導入模塊: from indico.modules.auth import Identity [as 別名]
# 或者: from indico.modules.auth.Identity import find_all [as 別名]
def get_user_from_identifier(settings, identifier):
"""Get an actual User object from an identifier"""
providers = list(auth.strip() for auth in settings.get('authenticators').split(','))
identities = Identity.find_all(Identity.provider.in_(providers), Identity.identifier == identifier)
if identities:
return sorted(identities, key=lambda x: providers.index(x.provider))[0].user
for provider in providers:
try:
identity_info = multipass.get_identity(provider, identifier)
except IdentityRetrievalFailed:
continue
if identity_info is None:
continue
if not identity_info.provider.settings.get('trusted_email'):
continue
emails = {email.lower() for email in identity_info.data.getlist('email') if email}
if not emails:
continue
user = User.find_first(~User.is_deleted, User.all_emails.in_(list(emails)))
if user:
return user