Fix first CAS connection problem

`user` was not returned by configure_user
This commit is contained in:
Théophile Bastian 2017-10-15 17:09:14 +02:00
parent 7797314c09
commit 865a249002
2 changed files with 5 additions and 3 deletions

View file

@ -1,6 +1,5 @@
from django_cas_ng.backends import CASBackend from django_cas_ng.backends import CASBackend
from .models import CasUser from .models import CasUser
from . import rhosts
class BOcalCASBackend(CASBackend): class BOcalCASBackend(CASBackend):
@ -11,3 +10,4 @@ class BOcalCASBackend(CASBackend):
def configure_user(self, user): def configure_user(self, user):
casUser = CasUser(user=user) casUser = CasUser(user=user)
casUser.save() casUser.save()
return user

View file

@ -71,9 +71,11 @@ def grantBOcalPrivileges(user):
def requireCasUser(fct): def requireCasUser(fct):
def hasCas(user):
return CasUser.objects.filter(user=user).count() > 0
def wrap(user, *args, **kwargs): def wrap(user, *args, **kwargs):
qs = CasUser.objects.filter(user=user) if not hasCas(user):
if not qs.count() > 0:
return return
return fct(user, *args, **kwargs) return fct(user, *args, **kwargs)
return wrap return wrap