diff --git a/bocal_auth/cas_backend.py b/bocal_auth/cas_backend.py index ed50d2b..af8e0b8 100644 --- a/bocal_auth/cas_backend.py +++ b/bocal_auth/cas_backend.py @@ -1,6 +1,5 @@ from django_cas_ng.backends import CASBackend from .models import CasUser -from . import rhosts class BOcalCASBackend(CASBackend): @@ -11,3 +10,4 @@ class BOcalCASBackend(CASBackend): def configure_user(self, user): casUser = CasUser(user=user) casUser.save() + return user diff --git a/bocal_auth/rhosts.py b/bocal_auth/rhosts.py index 2a17323..1b9230e 100644 --- a/bocal_auth/rhosts.py +++ b/bocal_auth/rhosts.py @@ -71,9 +71,11 @@ def grantBOcalPrivileges(user): def requireCasUser(fct): + def hasCas(user): + return CasUser.objects.filter(user=user).count() > 0 + def wrap(user, *args, **kwargs): - qs = CasUser.objects.filter(user=user) - if not qs.count() > 0: + if not hasCas(user): return return fct(user, *args, **kwargs) return wrap