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


Python UserSocialAuth.create_social_auth方法代码示例

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


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

示例1: test_simple

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_social_auth [as 别名]
 def test_simple(self):
     UserSocialAuth.create_social_auth(self.user, '1234', 'github')
     self.login_as(self.user)
     url = reverse('sentry-api-0-user-social-identities-index', kwargs={
         'user_id': self.user.id,
     })
     response = self.client.get(url)
     assert response.status_code == 200, response.content
     assert len(response.data) == 1
     assert response.data[0]['provider'] == 'github'
开发者ID:Kayle009,项目名称:sentry,代码行数:12,代码来源:test_user_social_identities_index.py

示例2: add_auth_id

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_social_auth [as 别名]
    def add_auth_id(self, auth_str):
        """
        Add a social auth identifier for this user.

        The `auth_str` should be in the format '{provider}:{uid}'
        this is useful for adding multiple unique email addresses.

        Example::

            user = User.objects.get(username='foo')
            user.add_auth_id('email:[email protected]')
        """
        provider, uid = auth_str.split(':')
        UserSocialAuth.create_social_auth(self, uid, provider)
开发者ID:kkszysiu,项目名称:julython.org,代码行数:16,代码来源:models.py

示例3: vkontakte_view

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

示例4: test_can_disconnect

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_social_auth [as 别名]
 def test_can_disconnect(self):
     auth = UserSocialAuth.create_social_auth(self.user, '1234', 'github')
     url = reverse('sentry-api-0-user-social-identity-details', kwargs={
         'user_id': self.user.id,
         'identity_id': auth.id,
     })
     with self.settings(GITHUB_APP_ID='app-id', GITHUB_API_SECRET='secret'):
         response = self.client.delete(url)
         assert response.status_code == 204
         assert not len(UserSocialAuth.objects.filter(user=self.user))
开发者ID:Kayle009,项目名称:sentry,代码行数:12,代码来源:test_user_social_identity_details.py

示例5: associate_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_social_auth [as 别名]
def associate_user(backend, user, uid, social_user=None, *args, **kwargs):
    """Associate user social account with user instance."""
    if social_user or not user:
        return None

    try:
        social = UserSocialAuth.create_social_auth(user, uid, backend.name)
    except IntegrityError:
        # Protect for possible race condition, those bastard with FTL
        # clicking capabilities, check issue #131:
        #   https://github.com/omab/django-social-auth/issues/131
        return social_auth_user(backend, uid, user, social_user=social_user, *args, **kwargs)
    else:
        return {"social_user": social, "user": social.user, "new_association": True}
开发者ID:ForkRepo,项目名称:sentry,代码行数:16,代码来源:social.py

示例6: associate_user

# 需要导入模块: from social_auth.models import UserSocialAuth [as 别名]
# 或者: from social_auth.models.UserSocialAuth import create_social_auth [as 别名]
def associate_user(backend, user, uid, social_user=None, *args, **kwargs):
    """Associate user social account with user instance."""
    if social_user or not user:
        return None

    try:
        social = UserSocialAuth.create_social_auth(user, uid, backend.name)
    except Exception, e:
        if not SOCIAL_AUTH_MODELS_MODULE.is_integrity_error(e):
            raise
        # Protect for possible race condition, those bastard with FTL
        # clicking capabilities, check issue #131:
        #   https://github.com/omab/django-social-auth/issues/131
        return social_auth_user(backend, uid, user, social_user=social_user,
                                *args, **kwargs)
开发者ID:AaronLaw,项目名称:django-social-auth,代码行数:17,代码来源:social.py

示例7: test_login_user

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


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