本文整理汇总了Python中social_auth.models.UserSocialAuth.get_user_by_email方法的典型用法代码示例。如果您正苦于以下问题:Python UserSocialAuth.get_user_by_email方法的具体用法?Python UserSocialAuth.get_user_by_email怎么用?Python UserSocialAuth.get_user_by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类social_auth.models.UserSocialAuth
的用法示例。
在下文中一共展示了UserSocialAuth.get_user_by_email方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_user
# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import get_user_by_email [as 别名]
def create_user(backend, details, response, uid, username, user=None, *args,
**kwargs):
"""Create user. Depends on get_username pipeline."""
if user:
return {'user': user}
if not username:
return None
email = details.get('email') or None
try:
UserSocialAuth.get_user_by_email(email=email)
raise AuthException(backend, _('This email is already used by other account. If it is your account, login and connect it on profile edit page.'))
except ObjectDoesNotExist:
pass
return {
'user': UserSocialAuth.create_user(username=username, email=email),
'is_new': True
}
示例2: associate_by_email
# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import get_user_by_email [as 别名]
def associate_by_email(details, user=None, *args, **kwargs):
"""Return user entry with same email address as one returned on details."""
if user:
return None
email = details.get('email')
if email:
# try to associate accounts registered with the same email address,
# only if it's a single object. AuthException is raised if multiple
# objects are returned
try:
return {'user': UserSocialAuth.get_user_by_email(email=email)}
except MultipleObjectsReturned:
raise AuthException(kwargs['backend'], 'Not unique email address.')
except ObjectDoesNotExist:
pass