refactor: use the Features class to know if a feature is available

instead of simply looking at the configuration
This commit is contained in:
Éloi Rivard 2024-12-05 12:20:26 +01:00
parent 650391891a
commit 6d8799d052
No known key found for this signature in database
GPG key ID: 7EDA204EA57DD184
3 changed files with 4 additions and 4 deletions

View file

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

View file

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

View file

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