Facebook connect doesn't note when FB account already connected #79

jaylett opened this Issue May 11, 2011 · 0 comments

2 participants


If you're logged into the Django site and hit the Facebook connect button, the facebook_connect view (which is the callback post-FB authentication) does not distinguish between having a pre-existing FacebookProfile object for the current user, and having one for a different user. We're doing the following to separate that out into a separate failure case:

def facebook_connect(request, template='socialregistration/facebook.html',
    extra_context=dict(), prelinked_template='socialregistration/facebook_prelinked.html'):
    View to handle connecting existing django accounts with facebook
    if request.facebook.uid is None or request.user.is_authenticated() is False:
        return render_to_response(template, extra_context,

        profile = FacebookProfile.objects.get(uid=request.facebook.uid)
        # this means that the profile already exists; is it connected to this user?
        if profile.user != request.user:
            extra_context.update(dict(error=_("That Facebook profile is already connected to another user")))
            return render_to_response(prelinked_template, extra_context,
    except FacebookProfile.DoesNotExist:
        profile = FacebookProfile.objects.create(user=request.user,

    return HttpResponseRedirect(_get_next(request))

Otherwise, you'll keep on seeing the "connect via Facebook" button, and it'll keep on doing nothing, if you've already linked that Facebook user to another Django user.

@flashingpumpkin flashingpumpkin added a commit that referenced this issue Jul 31, 2012
@flashingpumpkin Fixed: #143 #142 #127 #79 c773adf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment