Fix backend

This commit is contained in:
Ludovic Stephan 2020-06-13 19:45:22 +02:00
parent 99e84f04ad
commit 1c9ecb5eb9

View file

@ -142,7 +142,7 @@ class ENSCASBackend:
class OldCASBackend: class OldCASBackend:
"""Authentication backend for old CAS accounts. """Authentication backend for old CAS accounts.
Given a CAS login, an entrance year and a password, first finds the matching Given a CAS login, an entrance year and a password, first finds the matching
OldCASAccount instance (if it exists), then checks the given password with OldCASAccount instance (if it exists), then checks the given password with
the user associated to this account. the user associated to this account.
""" """
@ -168,3 +168,10 @@ class OldCASBackend:
# Taken from Django's ModelBackend # Taken from Django's ModelBackend
is_active = getattr(user, "is_active", None) is_active = getattr(user, "is_active", None)
return is_active or is_active is None return is_active or is_active is None
# Django boilerplate.
def get_user(self, user_id):
try:
return UserModel.objects.get(pk=user_id)
except UserModel.DoesNotExist:
return None