Reputation: 4261
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?
thanks
Upvotes: 1
Views: 553
Reputation: 23512
Updated for latest Django / python-social-auth
This example checks if facebook is linked to the account. Replace facebook with a valid backend name.
'facebook' in user.social_auth.all().values_list("provider", flat=True)
Upvotes: 1
Reputation: 33420
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:
request.user.usersocialauth_set.values_list('provider')
Beware: a cosmic backward compatibility break was introduced in commit 7f967702. Read answer comment for detail.
Upvotes: 3