Skip to content

Commit

Permalink
Skip auth backends without get_user
Browse files Browse the repository at this point in the history
Closes #1601
  • Loading branch information
pennersr committed Feb 26, 2017
1 parent 1f77804 commit 360e695
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions allauth/account/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,15 @@ def login(self, request, user):
if not hasattr(user, 'backend'):
from .auth_backends import AuthenticationBackend
backends = get_backends()
for backend in backends:
if isinstance(backend, AuthenticationBackend):
backend = None
for b in backends:
if isinstance(b, AuthenticationBackend):
# prefer our own backend
backend = b
break
else:
# Pick one
backend = backends[0]
elif not backend and hasattr(b, 'get_user'):
# Pick the first vald one
backend = b
backend_path = '.'.join([backend.__module__,
backend.__class__.__name__])
user.backend = backend_path
Expand Down

0 comments on commit 360e695

Please sign in to comment.