Return Http403 if the home directory is not parsable instead of creating an error 500

This commit is contained in:
Tom Hubrecht 2022-02-22 17:26:21 +01:00
parent 9f3f2a4664
commit e4e4cff9e6

View file

@ -2,6 +2,7 @@ from authens.backends import ENSCASBackend
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend from django.contrib.auth.backends import ModelBackend
from django.core.exceptions import PermissionDenied
User = get_user_model() User = get_user_model()
@ -18,6 +19,12 @@ class CASBackend(ENSCASBackend):
return User.objects.create_user(username=username, email=email, full_name=name) return User.objects.create_user(username=username, email=email, full_name=name)
def _get_or_create(self, cas_login, attributes):
try:
return super()._get_or_create(cas_login, attributes)
except ValueError:
raise PermissionDenied
class PwdBackend(ModelBackend): class PwdBackend(ModelBackend):
"""Password authentication""" """Password authentication"""