I recently added an extra authentication backend to allow users to login using either their email address or username, but it seems to break django-social-auth since after enabling it, when I try to login through Facebook, I get the message Incorrect authentication service
The backend's code is:
class EmailBackend:
supports_object_permissions = False
supports_anonymous_user = False
supports_inactive_user = False
def authenticate(self, username=None, password=None):
if email_re.search(username):
try:
user = User.objects.get(email=username)
except User.DoesNotExist:
return None
else:
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
return None
if user.check_password(password):
return user
return None
def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None
I got the code snippet from Django snippets
My AUTHENTICATION_BACKENDS:
AUTHENTICATION_BACKENDS = (
'social_auth.backends.twitter.TwitterBackend',
'social_auth.backends.facebook.FacebookBackend',
'apps.members.backends.EmailBackend',
)