Return Http403 if the home directory is not parsable instead of creating an error 500
This commit is contained in:
parent
9f3f2a4664
commit
e4e4cff9e6
1 changed files with 7 additions and 0 deletions
|
@ -2,6 +2,7 @@ from authens.backends import ENSCASBackend
|
|||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.backends import ModelBackend
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
@ -18,6 +19,12 @@ class CASBackend(ENSCASBackend):
|
|||
|
||||
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):
|
||||
"""Password authentication"""
|
||||
|
|
Loading…
Reference in a new issue