Skip to content

Commit

Permalink
wip: remove some flask warnings (to be tested)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonadoni committed Jul 9, 2024
1 parent cdaf4a6 commit 6a2161e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
25 changes: 11 additions & 14 deletions reana_server/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -69,6 +77,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."""
Expand All @@ -79,20 +90,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):
Expand Down

0 comments on commit 6a2161e

Please sign in to comment.