Exemple #1
0
 def authenticate(self, request=None, username=None):
     user_class = LazyUser.get_user_class()
     try:
         return user_class.objects.get(
             **{get_user_model().USERNAME_FIELD: username})
     except user_class.DoesNotExist:
         return None
 def authenticate(self, username=None):
     user_class = LazyUser.get_user_class()
     try:
         return user_class.objects.get(
             **{LAZYSIGNUP_USER_NAME_FIELD: username})
     except user_class.DoesNotExist:
         return None
 def authenticate(self, request=None, username=None):
     user_class = LazyUser.get_user_class()
     try:
         return user_class.objects.get(**{
             get_user_model().USERNAME_FIELD: username
         })
     except user_class.DoesNotExist:
         return None
Exemple #4
0
 def test_backend_get_custom_user_class(self):
     # The get_user method on the backend should also return instances of
     # the custom user class.
     lazy_view(self.request)
     backend = LazySignupBackend()
     user_class = LazyUser.get_user_class()
     pk = user_class.objects.all()[0].pk
     self.assertEqual(user_class, type(backend.get_user(pk)))
Exemple #5
0
 def test_backend_get_custom_user_class(self):
     # The get_user method on the backend should also return instances of
     # the custom user class.
     lazy_view(self.request)
     backend = LazySignupBackend()
     user_class = LazyUser.get_user_class()
     pk = user_class.model.objects.all()[0].pk
     self.assertEqual(user_class, type(backend.get_user(pk)))
 def get_user(self, user_id):
     # Annotate the user with our backend so it's always available,
     # not just when authenticate() has been called. This will be
     # used by the is_lazy_user filter.
     user_class = LazyUser.get_user_class()
     try:
         user = user_class.objects.get(pk=user_id)
     except user_class.DoesNotExist:
         user = None
     else:
         user.backend = 'lazysignup.backends.LazySignupBackend'
     return user
Exemple #7
0
 def get_user(self, user_id):
     # Annotate the user with our backend so it's always available,
     # not just when authenticate() has been called. This will be
     # used by the is_lazy_user filter.
     user_class = LazyUser.get_user_class()
     try:
         user = user_class.objects.get(pk=user_id)
     except user_class.DoesNotExist:
         user = None
     else:
         user.backend = 'lazysignup.backends.LazySignupBackend'
     return user
Exemple #8
0
 def test_user_field(self):
     # We should find that our LAZSIGNUP_CUSTOM_USER setting has been
     # respected.
     self.assertEqual(get_user_model(), LazyUser.get_user_class())
Exemple #9
0
 def test_user_field(self):
     # We should find that our LAZSIGNUP_CUSTOM_USER setting has been
     # respected.
     self.assertEqual(get_user_model(), LazyUser.get_user_class())
 def authenticate(self, username=None):
     user_class = LazyUser.get_user_class()
     try:
         return user_class.objects.get(username=username)
     except user_class.DoesNotExist:
         return None
 def authenticate(self, request, username=None):
     user_class = LazyUser.get_user_class()
     try:
         return user_class.objects.get(username=username)
     except user_class.DoesNotExist:
         return None
Exemple #12
0
 def testUserField(self):
     # We should find that our LAZSIGNUP_CUSTOM_USER setting has been
     # respected.
     self.assertEqual(CustomUser, LazyUser.get_user_class())