|
|
@ -1,5 +1,4 @@ |
|
|
from django.contrib.auth.backends import ModelBackend |
|
|
from django.contrib.auth.backends import ModelBackend |
|
|
<<<<<<< HEAD |
|
|
|
|
|
from accounts_app.models import BaseAccount, UserProfile |
|
|
from accounts_app.models import BaseAccount, UserProfile |
|
|
from abonapp.models import Abon |
|
|
from abonapp.models import Abon |
|
|
|
|
|
|
|
|
@ -41,23 +40,4 @@ class CustomAuthBackend(ModelBackend): |
|
|
except BaseAccount.DoesNotExist: |
|
|
except BaseAccount.DoesNotExist: |
|
|
return None |
|
|
return None |
|
|
return user if self.user_can_authenticate(user) else None |
|
|
return user if self.user_can_authenticate(user) else None |
|
|
======= |
|
|
|
|
|
from .models import BaseAccount, UserProfile |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CustomAuthBackend(ModelBackend): |
|
|
|
|
|
|
|
|
|
|
|
def authenticate(self, request, username=None, password=None, **kwargs): |
|
|
|
|
|
if username is None: |
|
|
|
|
|
username = kwargs.get(UserModel.USERNAME_FIELD) |
|
|
|
|
|
try: |
|
|
|
|
|
user = UserModel._default_manager.get_by_natural_key(username) |
|
|
|
|
|
except UserModel.DoesNotExist: |
|
|
|
|
|
# Run the default password hasher once to reduce the timing |
|
|
|
|
|
# difference between an existing and a non-existing user (#20760). |
|
|
|
|
|
UserModel().set_password(password) |
|
|
|
|
|
else: |
|
|
|
|
|
if user.check_password(password) and self.user_can_authenticate(user): |
|
|
|
|
|
return user |
|
|
|
|
|
>>>>>>> bcdd33ea0fadafe7b09f2c748b231ecf5386e8f9 |
|
|
|