forked from ScoDoc/ScoDoc
CAS: id par défaut
This commit is contained in:
parent
b1e6a7d471
commit
cdb0cf99ed
@ -23,7 +23,8 @@ def after_cas_login():
|
|||||||
if ScoDocSiteConfig.is_cas_enabled() and ("CAS_ATTRIBUTES" in flask.session):
|
if ScoDocSiteConfig.is_cas_enabled() and ("CAS_ATTRIBUTES" in flask.session):
|
||||||
# Lookup user:
|
# Lookup user:
|
||||||
cas_id = flask.session["CAS_ATTRIBUTES"].get(
|
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:
|
if cas_id is not None:
|
||||||
user = User.query.filter_by(cas_id=cas_id).first()
|
user = User.query.filter_by(cas_id=cas_id).first()
|
||||||
|
@ -546,18 +546,21 @@ class UserRole(db.Model):
|
|||||||
role_dept, of the forme "Role_Dept".
|
role_dept, of the forme "Role_Dept".
|
||||||
role is a Role instance, dept is a string, or None.
|
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:
|
if len(fields) != 2:
|
||||||
current_app.logger.warning(
|
current_app.logger.warning(
|
||||||
f"role_dept_from_string: Invalid role_dept '{role_dept}'"
|
f"role_dept_from_string: Invalid role_dept '{role_dept}'"
|
||||||
)
|
)
|
||||||
raise ScoValueError("Invalid role_dept")
|
raise ScoValueError("Invalid role_dept")
|
||||||
role_name, dept = fields
|
role_name, dept = fields
|
||||||
|
dept = dept.strip() if dept else ""
|
||||||
if dept == "":
|
if dept == "":
|
||||||
dept = None
|
dept = None
|
||||||
|
|
||||||
role = Role.query.filter_by(name=role_name).first()
|
role = Role.query.filter_by(name=role_name).first()
|
||||||
if role is None:
|
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)
|
return (role, dept)
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class ConfigCASForm(FlaskForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
cas_attribute_id = StringField(
|
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
|
description="""Le champs CAS qui sera considéré comme l'id unique des
|
||||||
comptes utilisateurs.""",
|
comptes utilisateurs.""",
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# -*- mode: python -*-
|
# -*- mode: python -*-
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
SCOVERSION = "9.4.52"
|
SCOVERSION = "9.4.53"
|
||||||
|
|
||||||
SCONAME = "ScoDoc"
|
SCONAME = "ScoDoc"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user