diff -ur -x '*.pyc' django_original/django/contrib/auth/__init__.py django/django/contrib/auth/__init__.py
old
|
new
|
|
41 | 41 | If the given credentials are valid, return a User object. |
42 | 42 | """ |
43 | 43 | for backend in get_backends(): |
44 | | try: |
| 44 | if hasattr(backend, 'can_authenticate'): |
| 45 | if not backend.can_authenticate(credentials): |
| 46 | continue |
45 | 47 | user = backend.authenticate(**credentials) |
46 | | except TypeError: |
47 | | # This backend doesn't accept these credentials as arguments. Try the next one. |
48 | | continue |
| 48 | else: |
| 49 | # fall back to the old method |
| 50 | try: |
| 51 | user = backend.authenticate(**credentials) |
| 52 | except TypeError: |
| 53 | # This backend doesn't accept these credentials as arguments. Try the next one. |
| 54 | continue |
49 | 55 | if user is None: |
50 | 56 | continue |
51 | 57 | # Annotate the user object with the path of the backend. |
diff -ur -x '*.pyc' django_original/django/contrib/auth/backends.py django/django/contrib/auth/backends.py
old
|
new
|
|
7 | 7 | """ |
8 | 8 | supports_inactive_user = True |
9 | 9 | |
| 10 | def can_authenticate(self, credentials): |
| 11 | # we don't check anything here for backwards compatibility |
| 12 | # for any classes that subclass us. |
| 13 | # |
| 14 | #return 'username' in credentials and 'password' in credentials |
| 15 | return True |
| 16 | |
10 | 17 | # TODO: Model, login attribute name and password attribute name should be |
11 | 18 | # configurable. |
12 | 19 | def authenticate(self, username=None, password=None): |
… |
… |
|
79 | 86 | # Create a User object if not already in the database? |
80 | 87 | create_unknown_user = True |
81 | 88 | |
| 89 | def can_authenticate(self, credentials): |
| 90 | # we don't check anything here for backwards compatibility |
| 91 | # for any classes that subclass us. |
| 92 | # |
| 93 | #return 'remote_user' in credentials |
| 94 | return True |
| 95 | |
82 | 96 | def authenticate(self, remote_user): |
83 | 97 | """ |
84 | 98 | The username passed as ``remote_user`` is considered trusted. This |