CAS: id par défaut

This commit is contained in:
Emmanuel Viennet 2023-02-27 12:01:26 +01:00 committed by iziram
parent b98d9c2036
commit 2a8ee95df7
4 changed files with 9 additions and 5 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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.""",
)

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.4.52"
SCOVERSION = "9.4.53"
SCONAME = "ScoDoc"