From cdb0cf99edf6212d730e8a4f4b155f6314d9318b Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 27 Feb 2023 12:01:26 +0100 Subject: [PATCH] =?UTF-8?q?CAS:=20id=20par=20d=C3=A9faut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/auth/cas.py | 3 ++- app/auth/models.py | 7 +++++-- app/forms/main/config_cas.py | 2 +- sco_version.py | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/auth/cas.py b/app/auth/cas.py index 4b478eaf..2a037744 100644 --- a/app/auth/cas.py +++ b/app/auth/cas.py @@ -23,7 +23,8 @@ def after_cas_login(): if ScoDocSiteConfig.is_cas_enabled() and ("CAS_ATTRIBUTES" in flask.session): # Lookup user: cas_id = flask.session["CAS_ATTRIBUTES"].get( - "cas:" + ScoDocSiteConfig.get("cas_attribute_id") + "cas:" + ScoDocSiteConfig.get("cas_attribute_id"), + flask.session.get("CAS_USERNAME"), ) if cas_id is not None: user = User.query.filter_by(cas_id=cas_id).first() diff --git a/app/auth/models.py b/app/auth/models.py index c7ef016d..d39b0274 100644 --- a/app/auth/models.py +++ b/app/auth/models.py @@ -546,18 +546,21 @@ class UserRole(db.Model): role_dept, of the forme "Role_Dept". role is a Role instance, dept is a string, or None. """ - fields = role_dept.split("_", 1) # maxsplit=1, le dept peut contenir un "_" + fields = role_dept.strip().split("_", 1) + # maxsplit=1, le dept peut contenir un "_" if len(fields) != 2: current_app.logger.warning( f"role_dept_from_string: Invalid role_dept '{role_dept}'" ) raise ScoValueError("Invalid role_dept") role_name, dept = fields + dept = dept.strip() if dept else "" if dept == "": dept = None + role = Role.query.filter_by(name=role_name).first() if role is None: - raise ScoValueError("role %s does not exists" % role_name) + raise ScoValueError(f"role {role_name} does not exists") return (role, dept) diff --git a/app/forms/main/config_cas.py b/app/forms/main/config_cas.py index 217b274f..ef8b84cf 100644 --- a/app/forms/main/config_cas.py +++ b/app/forms/main/config_cas.py @@ -44,7 +44,7 @@ class ConfigCASForm(FlaskForm): ) cas_attribute_id = StringField( - label="Attribut CAS utilisé comme id", + label="Attribut CAS utilisé comme id (laissez vide pour prendre l'id par défaut)", description="""Le champs CAS qui sera considéré comme l'id unique des comptes utilisateurs.""", ) diff --git a/sco_version.py b/sco_version.py index b0481907..77a09ba3 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.4.52" +SCOVERSION = "9.4.53" SCONAME = "ScoDoc"