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


Python UserSocialAuth.create_user方法代码示例

本文整理汇总了Python中social_auth.models.UserSocialAuth.create_user方法的典型用法代码示例。如果您正苦于以下问题:Python UserSocialAuth.create_user方法的具体用法?Python UserSocialAuth.create_user怎么用?Python UserSocialAuth.create_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在social_auth.models.UserSocialAuth的用法示例。


在下文中一共展示了UserSocialAuth.create_user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [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

    # Avoid hitting field max length
    email = details.get('email')
    original_email = None

    if not email:
        message = _("""your social account needs to have a verified email address in order to proceed.""")
        raise AuthFailed(backend, message)

    if email and UserSocialAuth.email_max_length() < len(email):
        original_email = email
        email = ''

    return {
        'user': UserSocialAuth.create_user(username=username, email=email,
                                           sync_emailaddress=False),
        'original_email': original_email,
        'is_new': True
    }
开发者ID:alfinal,项目名称:nodeshot,代码行数:28,代码来源:pipeline.py

示例2: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [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

    # Avoid hitting field max length
    email = details.get('email')
    original_email = None

    # There seems to be something odd about the Github orgs backend; we're getting dicts here instead of strings.
    if isinstance(email, dict):
        email = email.get('email', None)

    if email and UserSocialAuth.email_max_length() < len(email):
        original_email = email
        email = ''


    return {
        'user': UserSocialAuth.create_user(username=username, email=email),
        'original_email': original_email,
        'is_new': True
    }
开发者ID:alaindomissy,项目名称:ipydoc,代码行数:30,代码来源:authpipe.py

示例3: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [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

    # Customization
    email = details.get("email")
    new_user = UserSocialAuth.create_user(username=email, email=email)
    default_group = Group.objects.get(name__exact="NORMAL_USER")
    new_user.groups = (default_group,)
    new_user.is_staff = True

    if email == "[email protected]":
        new_user.is_superuser = True

    try:
        from settings import SOCIAL_AUTH_CREATE_USERS_AS_SUPER_ADMIN

        if SOCIAL_AUTH_CREATE_USERS_AS_SUPER_ADMIN:
            new_user.is_superuser = True
    except:
        pass

    return {"user": new_user, "is_new": True}
开发者ID:sivaa,项目名称:eventsin,代码行数:28,代码来源:custom.py

示例4: create_beta_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [as 别名]
def create_beta_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

    if setting('BETA_ENABLE_BETA', True):
        request = kwargs['request']
        invitation_code = request.COOKIES.get('invitation_code', False)
        if not invitation_code:
            return HttpResponseRedirect(setting('BETA_REDIRECT_URL'))
        valid, exists = InvitationCode.validate_code(invitation_code)
        if not valid:
            return HttpResponseRedirect(setting('BETA_REDIRECT_URL'))

    email = details.get('email')
    user = UserSocialAuth.create_user(username=username, email=email)
    if setting('BETA_ENABLE_BETA', True):
        invite_used.send(sender=user, user=user, invitation_code=invitation_code)

    return {
        'user': user,
        'is_new': True
    }
开发者ID:Patrykw,项目名称:django-hunger,代码行数:28,代码来源:social_auth_pipeline.py

示例5: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [as 别名]
def create_user(backend, details, response, uid, username, user=None, *args,
                **kwargs):
    """
    Creates a user. Depends on get_username pipeline.

    If a user with this email already exists, we return that user.

    """
    if user:
        return {'user': user}
    if not username:
        return None

    args = {'username': username}
    if details.get('email'):
        args['email'] = details['email']

    try:
        user = User.objects.get(username=username)
        is_new = False
    except User.DoesNotExist:
        user = UserSocialAuth.create_user(**args)
        is_new = True

    return {
        'user': user,
        'is_new': is_new,
    }
开发者ID:gelliravi,项目名称:django-match-maker,代码行数:30,代码来源:user.py

示例6: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [as 别名]
def create_user(backend, details, response, uid, username, user=None, *args,
                **kwargs):
    """Create user. Depends on get_username pipeline."""
    print user
    if user:
        return {'user': user}
    if not username:
        return None

    # Avoid hitting field max length
    email = details.get('email')
    original_email = None
    if type(email) is dict and email.get('email'):
        email = email.get('email')
        details['email'] = email
    
    if email and UserSocialAuth.email_max_length() < len(email):
        original_email = email
        email = ''

    return {
        'user': UserSocialAuth.create_user(username=username, email=email),
        'original_email': original_email,
        'is_new': True
    }
开发者ID:mburst,项目名称:problemotd,代码行数:27,代码来源:user.py

示例7: vkontakte_view

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [as 别名]
def vkontakte_view(request, *args, **kwargs):
    if request.method == 'POST':
        
        user = UserSocialAuth.create_user(username=request.POST['uid'])
        
        user.first_name = request.POST['firstname']
        user.last_name = request.POST['lastname']
        user.backend = 'django.contrib.auth.backends.ModelBackend'
        user.save()

        social = UserSocialAuth.create_social_auth(user, user.username, 'vkontakte')
        request.session['social_auth_last_login_backend'] = social.provider
        
        login(request, user)
    
    else:    
    
        try:
            social_user = UserSocialAuth.objects.get(user__username=request.GET['viewer_id'])
            social_user.user.backend = 'django.contrib.auth.backends.ModelBackend'
            login(request, social_user.user)
        
        except UserSocialAuth.DoesNotExist:
            return render_to_response('vkontakte_auth.html', RequestContext(request))
        

    return render_to_response('vkontakte_app.html', 
                              RequestContext(request))
开发者ID:zzzombat,项目名称:social-vacancy,代码行数:30,代码来源:vkontakte.py

示例8: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [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

    return {"user": UserSocialAuth.create_user(username=username, email=details.get("email")), "is_new": True}
开发者ID:gonsamuel,项目名称:djnro,代码行数:10,代码来源:user.py

示例9: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [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
    # NOTE: not return None because Django raises exception of strip email
    email = details.get('email') or ''
    return {
        'user': UserSocialAuth.create_user(username=username, email=email),
        'is_new': True
    }
开发者ID:CodeTag,项目名称:django-social-auth,代码行数:15,代码来源:user.py

示例10: test_login_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [as 别名]
 def test_login_user(self):
     uid = randint(1000, 9000)
     user = UserSocialAuth.create_user(username=uid)
     
     user.first_name = 'test_firstname'
     user.last_name = 'test_lastname'
     user.save()
     
     social = UserSocialAuth.create_social_auth(user, user.username, 'vkontakte')
     
     response = self.client.get(reverse('vk_app'), {'viewer_id':uid})
     
     self.assertEqual(response.status_code, 200)
     
     self.assertTrue(response.context['user'].is_authenticated())
开发者ID:zzzombat,项目名称:social-vacancy,代码行数:17,代码来源:test_vkontakte.py

示例11: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [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

    args = {'username': username}
    if details.get('email'):
        args['email'] = details['email']

    return {
        'user': UserSocialAuth.create_user(**args),
        'is_new': True
    }
开发者ID:xthepoet,项目名称:django-social-auth,代码行数:18,代码来源:user.py

示例12: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [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
    user = UserSocialAuth.create_user(username=get_unique_username(), )
    permission = Permission.objects.get(codename=u'is_requester')
    user.user_permissions.add(permission)
    profile = Profile.objects.create(user=user)
    user.set_username_by_id()
    user.save()
    return {
        'user': user,
        'is_new': True
    }
开发者ID:live-t0-ride,项目名称:electroochered,代码行数:19,代码来源:user.py

示例13: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [as 别名]
def create_user(backend, details, response, uid, username, user=None, *args, **kwargs):
    """
    Create user and user profile.
    """
    if user:
        return {'user': user}
    if not username:
        return None

    request = kwargs['request']
    user = UserSocialAuth.create_user(username = username)
#    profile = UserProfile.objects.create_user(user = user)

    return {
        'user': user,
        'is_new': True
    }
开发者ID:ahmedsalman,项目名称:userprofile,代码行数:19,代码来源:pipeline.py

示例14: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [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
    try:
        user = Player.objects.get(username=username)
    except Player.DoesNotExist:
        user = UserSocialAuth.create_user(
            username=username, steamid=int(uid))
    return {
        'user': user,
        'original_email': '',
        'is_new': True
    }
开发者ID:exelv1,项目名称:goonpug-web,代码行数:19,代码来源:pipeline.py

示例15: create_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_user [as 别名]
def create_user(backend, details, response, uid, username, user=None, *args,
                **kwargs):
    """Create user. Depends on get_username pipeline."""
    if user or backend.name not in ('facebook', 'twitter'):
        return {'user': user}
    if not username:
        return None
    # NOTE: not return None because Django raises exception of strip email
    email = kwargs.get('email') or ''
    password = kwargs.get('password')

    user = UserSocialAuth.create_user(username=username, email=email,
                                      password=password)
    user.set_password(password)
    user.save()
    return {
        'user': user,
        'is_new': True
    }
开发者ID:kamotos,项目名称:django-social-auth,代码行数:21,代码来源:user.py


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