def save_user(self, request, sociallogin, form=None):
        user = get_user_model().objects.filter(
            email=sociallogin.user.email, ).first()
        if not user:
            user = super(SocialAccountAdapter, self).save_user(request,
                                                               sociallogin,
                                                               form=None)
            # save is_social
            user.is_social = True
            user.save()
        else:
            request.user = user
            _add_social_account(request, sociallogin)

        return user
Пример #2
0
def complete_social_login(request, sociallogin, response):
    """Custom call to _complete_social_login."""
    assert not sociallogin.is_existing
    sociallogin.lookup()
    try:
        get_adapter(request).pre_social_login(request, sociallogin)
        signals.pre_social_login.send(sender=SocialLogin,
                                      request=request,
                                      sociallogin=sociallogin)
    except ImmediateHttpResponse as e:
        return e.response
    process = sociallogin.state.get('process')
    if process == AuthProcess.REDIRECT:
        return _social_login_redirect(request, sociallogin)
    elif process == AuthProcess.CONNECT:
        return _add_social_account(request, sociallogin)
    else:
        return _complete_social_login(request, sociallogin, response)
Пример #3
0
 def form_valid(self, form):
     # Authentication is OK, log in and request to connect accounts
     form.login(self.request)
     return _add_social_account(self.request, self.sociallogin)
Пример #4
0
 def form_valid(self, form):
     # Authentication is OK, log in and request to connect accounts
     form.login(self.request)
     return _add_social_account(self.request, self.sociallogin)