Skip to content

Commit

Permalink
Merge branch 'pashinin-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
danfairs committed Sep 9, 2017
2 parents 3df1e76 + 1e69193 commit 0f25110
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lazysignup/backends.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from django.contrib.auth.backends import ModelBackend
from lazysignup.models import LazyUser
from django.contrib.auth import get_user_model


class LazySignupBackend(ModelBackend):

def authenticate(self, username=None):
user_class = LazyUser.get_user_class()
try:
return user_class.objects.get(username=username)
return user_class.objects.get(**{
get_user_model().USERNAME_FIELD: username
})
except user_class.DoesNotExist:
return None

Expand Down
3 changes: 2 additions & 1 deletion lazysignup/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from lazysignup.utils import is_lazy_user
from lazysignup.signals import converted
from lazysignup import constants
from django.contrib.auth import get_user_model
DEFAULT_BLACKLIST = (
'slurp',
'googlebot',
Expand All @@ -31,7 +32,7 @@ def __hash__(self):
"""
return hash(str(self))

username_field = 'username'
username_field = get_user_model().USERNAME_FIELD

def create_lazy_user(self):
""" Create a lazy user. Returns a 2-tuple of the underlying User
Expand Down

0 comments on commit 0f25110

Please sign in to comment.