Browse Source

correction d’un bug dans le backends de connection

Élie Bouttier 7 years ago
parent
commit
0004eb8403
1 changed files with 3 additions and 4 deletions
  1. 3 4
      adhesions/backends.py

+ 3 - 4
adhesions/backends.py

@@ -1,8 +1,7 @@
-from django.contrib.auth.models import User
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.auth.backends import ModelBackend
 
-from .models import Adhesion
+from .models import User, Adhesion
 
 
 class AdhesionBackend(ModelBackend):
@@ -17,8 +16,8 @@ class AdhesionBackend(ModelBackend):
             return None
         user_type = ContentType.objects.get_for_model(User)
         try:
-            user = Adhesion.objects.get(adherent_type=user_type, id=adhesion_id).adherent
-        except Adhesion.DoesNotExist:
+            user = User.objects.get(adhesion__id=adhesion_id)
+        except User.DoesNotExist:
             User().set_password(password) # https://code.djangoproject.com/ticket/20760
         else:
             if user.check_password(password) and self.user_can_authenticate(user):