当前位置: 首页>>代码示例>>Python>>正文


Python UserSocialAuth.get_user_by_email方法代码示例

本文整理汇总了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
    }
开发者ID:vaal-,项目名称:djbookru,代码行数:22,代码来源:social_auth_pipelines.py

示例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
开发者ID:vaal-,项目名称:djbookru,代码行数:18,代码来源:associate.py


注:本文中的social_auth.models.UserSocialAuth.get_user_by_email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。