John John - 1 year ago 75
Python Question

What method to use to figure out if user is connected to facebook

I am using django-social-auth for facebook login. I am able to login user using "/facebook/login". But, I need to check if user is logged in using facebook on some other page. Is there a method in the module to check if user is logged in using facebook?


Answer Source

You can check if the user has any facebook account as such:

for usersocialauth in request.user.usersocialauth_set.all():
    print usersocialauth.provider

You might as well get the list of providers for the user:


Beware: a cosmic backward compatibility break was introduced in commit 7f967702. Read answer comment for detail.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download