Attempt to fix loading issues when oauth is not responding

This commit is contained in:
2025-06-03 11:07:35 +01:00
parent d5f63f4387
commit c5bd3d138e
2 changed files with 12 additions and 2 deletions

View File

@@ -8,4 +8,4 @@
"""Metadata for this python module.""" """Metadata for this python module."""
__version__ = "2025.5.20.8" __version__ = "2025.6.3"

View File

@@ -8,6 +8,7 @@
"""invenio module for I-Form theme.""" """invenio module for I-Form theme."""
from flask import g, has_request_context
from flask_login import login_required from flask_login import login_required
from invenio_records_marc21.ui.theme import current_identity_can_view from invenio_records_marc21.ui.theme import current_identity_can_view
@@ -34,7 +35,16 @@ class InvenioThemeIform(object):
@app.context_processor @app.context_processor
def inject_visibility(): def inject_visibility():
return {"can_view_marc21": current_identity_can_view()} def can_view_marc21():
try:
# Only check if we're in a request context and identity exists
if has_request_context() and hasattr(g, "identity") and g.identity:
return current_identity_can_view()
return False
except (AttributeError, RuntimeError):
return False
return {"can_view_marc21": can_view_marc21()}
app.extensions["invenio-theme-iform"] = self app.extensions["invenio-theme-iform"] = self