From 25a44508c4df2242403ef7d25dc0d8cc1360255c Mon Sep 17 00:00:00 2001
From: Maximilian Moser <maximilian.moser@tuwien.ac.at>
Date: Tue, 9 Jul 2024 10:10:33 +0200
Subject: [PATCH] Make Flask-Minify opt-in

* it looks like the extension may have been linked with issues regarding
  user-related operations such as login and file upload, so we decided
  to make it opt-in for now
---
 invenio_config_tuw/config.py | 3 +++
 invenio_config_tuw/ext.py    | 9 +++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/invenio_config_tuw/config.py b/invenio_config_tuw/config.py
index fc913aa..d248c74 100644
--- a/invenio_config_tuw/config.py
+++ b/invenio_config_tuw/config.py
@@ -52,6 +52,9 @@ CONFIG_TUW_READ_ONLY_MODE = False
 CONFIG_TUW_DISABLE_ERROR_MAILS = False
 """Disable registration of the SMTP mail handler to suppress warnings."""
 
+CONFIG_TUW_MINIFY_ENABLED = False
+"""Enable or disable the Flask-Minify extension."""
+
 
 # Invenio-Mail
 # ============
diff --git a/invenio_config_tuw/ext.py b/invenio_config_tuw/ext.py
index a9ffba5..fd7789b 100644
--- a/invenio_config_tuw/ext.py
+++ b/invenio_config_tuw/ext.py
@@ -78,7 +78,12 @@ class InvenioConfigTUW(object):
                 app.config[key] = app.config["DATACITE_USERNAME"]
 
     def init_minify(self, app):
-        """Initialize the Flask-Minify extension."""
-        if "flask-minify" not in app.extensions:
+        """Initialize the Flask-Minify extension.
+
+        It seems like this extension may cause issues with certain user-related
+        operations in the system and has thus been disabled by default.
+        """
+        minify_enabled = app.config.get("CONFIG_TUW_MINIFY_ENABLED", False)
+        if minify_enabled and "flask-minify" not in app.extensions:
             minify = Minify(app, static=False, go=False)
             app.extensions["flask-minify"] = minify
-- 
GitLab