Skip to content

Commit

Permalink
fix(jinjax): refresh jinjax global env after user logs in or out
Browse files Browse the repository at this point in the history
  • Loading branch information
mirekys committed Mar 1, 2024
1 parent 34e7d35 commit 7482d95
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions oarepo_ui/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from flask import Response, current_app
from invenio_base.utils import obj_or_import_string
from flask_login import user_logged_in, user_logged_out
from .signals import handle_user_change

import oarepo_ui.cli # noqa
from oarepo_ui.resources.templating.catalog import OarepoCatalog as Catalog
Expand Down Expand Up @@ -90,6 +92,7 @@ def __init__(self, app=None):

def init_app(self, app):
self.init_config(app)
self.connect_signals(app)
app.extensions["oarepo_ui"] = OARepoUIState(app)

def init_config(self, app):
Expand All @@ -105,3 +108,10 @@ def init_config(self, app):
for name, val in getattr(config, k).items():
if name not in app.config[k]:
app.config[k][name] = val



def connect_signals(self, app):
"""Register signal handlers."""
user_logged_in.connect(handle_user_change, app)
user_logged_out.connect(handle_user_change, app)
4 changes: 4 additions & 0 deletions oarepo_ui/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .proxies import current_oarepo_ui

def handle_user_change(app, user):
current_oarepo_ui.reinitialize_catalog()

0 comments on commit 7482d95

Please sign in to comment.