diff --git a/Dockerfile b/Dockerfile index 88d8be46..eec2c299 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # This file is part of REANA. -# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022, 2023 CERN. +# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 CERN. # # REANA is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. diff --git a/reana_server/ext.py b/reana_server/ext.py index 2a58c418..cce59b56 100644 --- a/reana_server/ext.py +++ b/reana_server/ext.py @@ -16,7 +16,15 @@ from reana_commons.config import REANA_LOG_FORMAT, REANA_LOG_LEVEL from werkzeug.exceptions import UnprocessableEntity +from invenio_oauthclient.signals import account_info_received +from flask_security.signals import user_registered + + from reana_server import config +from reana_server.utils import ( + _create_and_associate_local_user, + _create_and_associate_oauth_user, +) def handle_rate_limit_error(error: RateLimitExceeded): @@ -75,6 +83,9 @@ def init_app(self, app): self.init_config(app) self.init_error_handlers(app) + account_info_received.connect(_create_and_associate_oauth_user) + user_registered.connect(_create_and_associate_local_user) + @app.teardown_appcontext def shutdown_reana_db_session(response_or_exc): """Close session on app teardown.""" @@ -85,20 +96,6 @@ def shutdown_reana_db_session(response_or_exc): invenio_db.session.remove() return response_or_exc - @app.before_first_request - def connect_signals(): - """Connect OAuthClient signals.""" - from invenio_oauthclient.signals import account_info_received - from flask_security.signals import user_registered - - from .utils import ( - _create_and_associate_local_user, - _create_and_associate_oauth_user, - ) - - account_info_received.connect(_create_and_associate_oauth_user) - user_registered.connect(_create_and_associate_local_user) - def init_config(self, app): """Initialize configuration.""" for k in dir(config):