From 6d8799d05283579924669397e2cf178709eaf346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Thu, 5 Dec 2024 12:20:26 +0100 Subject: [PATCH] refactor: use the Features class to know if a feature is available instead of simply looking at the configuration --- canaille/__init__.py | 4 ++-- canaille/app/flask.py | 2 +- canaille/core/endpoints/account.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/canaille/__init__.py b/canaille/__init__.py index 06bd248f..3b84b72a 100644 --- a/canaille/__init__.py +++ b/canaille/__init__.py @@ -41,7 +41,7 @@ def setup_blueprints(app): app.register_blueprint(canaille.core.endpoints.bp) - if "CANAILLE_OIDC" in app.config: + if app.features.has_oidc: import canaille.oidc.endpoints app.register_blueprint(canaille.oidc.endpoints.bp) @@ -113,7 +113,7 @@ def create_app( setup_themer(app) setup_flask(app) - if "CANAILLE_OIDC" in app.config: + if app.features.has_oidc: from .oidc.oauth import setup_oauth setup_oauth(app) diff --git a/canaille/app/flask.py b/canaille/app/flask.py index 4713d92c..1c1e2a8e 100644 --- a/canaille/app/flask.py +++ b/canaille/app/flask.py @@ -47,7 +47,7 @@ def smtp_needed(): def wrapper(view_function): @wraps(view_function) def decorator(*args, **kwargs): - if current_app.config["CANAILLE"].get("SMTP"): + if current_app.features.has_smtp: return view_function(*args, **kwargs) message = _("No SMTP server has been configured") diff --git a/canaille/core/endpoints/account.py b/canaille/core/endpoints/account.py index 485afc13..f2f0e75f 100644 --- a/canaille/core/endpoints/account.py +++ b/canaille/core/endpoints/account.py @@ -68,7 +68,7 @@ def index(): if user.can_edit_self or user.can_manage_users: return redirect(url_for("core.account.profile_edition", edited_user=user)) - if "CANAILLE_OIDC" in current_app.config and user.can_use_oidc: + if current_app.features.has_oidc and user.can_use_oidc: return redirect(url_for("oidc.consents.consents")) return redirect(url_for("core.account.about"))