diff --git a/app/auth/cas.py b/app/auth/cas.py index 4b478eaf8..2a037744a 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 c7ef016dd..d39b02742 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 217b274f3..ef8b84cf3 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 b0481907f..77a09ba3d 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"