Option pour autoriser le CAS aux nouveaux utilisateurs: implements #701

This commit is contained in:
Emmanuel Viennet 2023-09-02 22:49:21 +02:00 committed by iziram
parent 62eea7fc47
commit da9818ddde
4 changed files with 21 additions and 0 deletions

View File

@ -40,6 +40,9 @@ class ConfigCASForm(FlaskForm):
cas_force = BooleanField(
"Forcer l'utilisation de CAS (tous les utilisateurs seront redirigés vers le CAS)"
)
cas_allow_for_new_users = BooleanField(
"Par défaut, autoriser le CAS aux nouveaux utilisateurs"
)
cas_server = StringField(
label="URL du serveur CAS",

View File

@ -17,6 +17,7 @@
{{ wtf.form_field(form.cas_enable) }}
{{ wtf.form_field(form.cas_force) }}
{{ wtf.form_field(form.cas_allow_for_new_users) }}
{{ wtf.form_field(form.cas_server) }}
{{ wtf.form_field(form.cas_login_route) }}
{{ wtf.form_field(form.cas_logout_route) }}

View File

@ -156,6 +156,13 @@ def config_cas():
flash("CAS " + ("activé" if form.data["cas_enable"] else "désactivé"))
if ScoDocSiteConfig.set("cas_force", form.data["cas_force"]):
flash("CAS " + ("forcé" if form.data["cas_force"] else "non forcé"))
if ScoDocSiteConfig.set(
"cas_allow_for_new_users", form.data["cas_allow_for_new_users"]
):
flash(
f"""CAS {'' if form.data['cas_allow_for_new_users'] else 'non'
} autorisé par défaut aux nouveaux"""
)
if ScoDocSiteConfig.set("cas_server", form.data["cas_server"]):
flash("URL du serveur CAS enregistrée")
if ScoDocSiteConfig.set("cas_login_route", form.data["cas_login_route"]):
@ -182,6 +189,9 @@ def config_cas():
elif request.method == "GET":
form.cas_enable.data = ScoDocSiteConfig.get("cas_enable")
form.cas_force.data = ScoDocSiteConfig.get("cas_force")
form.cas_allow_for_new_users.data = ScoDocSiteConfig.get(
"cas_allow_for_new_users"
)
form.cas_server.data = ScoDocSiteConfig.get("cas_server")
form.cas_login_route.data = ScoDocSiteConfig.get("cas_login_route")
form.cas_logout_route.data = ScoDocSiteConfig.get("cas_logout_route")

View File

@ -371,6 +371,12 @@ def create_user_form(user_name=None, edit=0, all_roles=True):
)
]
cas_enabled = ScoDocSiteConfig.is_cas_enabled()
if edit:
cas_allow_login_default = the_user.cas_allow_login
else:
cas_allow_login_default = int(
bool(ScoDocSiteConfig.get("cas_allow_for_new_users"))
)
descr += [
(
"email",
@ -408,6 +414,7 @@ def create_user_form(user_name=None, edit=0, all_roles=True):
"explanation": """ si CAS est activé.
Seul le super-administrateur peut changer ce réglage.""",
"enabled": current_user.is_administrator(),
"default": cas_allow_login_default,
},
),
(