From 865a2490026aa2362590cc25ebddf4b7ffd47d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Sun, 15 Oct 2017 17:09:14 +0200 Subject: [PATCH] Fix first CAS connection problem `user` was not returned by configure_user --- bocal_auth/cas_backend.py | 2 +- bocal_auth/rhosts.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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