1616from reana_commons .config import REANA_LOG_FORMAT , REANA_LOG_LEVEL
1717from werkzeug .exceptions import UnprocessableEntity
1818
19+ from invenio_oauthclient .signals import account_info_received
20+ from flask_security .signals import user_registered
21+
22+
1923from reana_server import config
24+ from reana_server .utils import (
25+ _create_and_associate_local_user ,
26+ _create_and_associate_oauth_user ,
27+ )
2028
2129
2230def handle_rate_limit_error (error : RateLimitExceeded ):
@@ -75,6 +83,9 @@ def init_app(self, app):
7583 self .init_config (app )
7684 self .init_error_handlers (app )
7785
86+ account_info_received .connect (_create_and_associate_oauth_user )
87+ user_registered .connect (_create_and_associate_local_user )
88+
7889 @app .teardown_appcontext
7990 def shutdown_reana_db_session (response_or_exc ):
8091 """Close session on app teardown."""
@@ -85,20 +96,6 @@ def shutdown_reana_db_session(response_or_exc):
8596 invenio_db .session .remove ()
8697 return response_or_exc
8798
88- @app .before_first_request
89- def connect_signals ():
90- """Connect OAuthClient signals."""
91- from invenio_oauthclient .signals import account_info_received
92- from flask_security .signals import user_registered
93-
94- from .utils import (
95- _create_and_associate_local_user ,
96- _create_and_associate_oauth_user ,
97- )
98-
99- account_info_received .connect (_create_and_associate_oauth_user )
100- user_registered .connect (_create_and_associate_local_user )
101-
10299 def init_config (self , app ):
103100 """Initialize configuration."""
104101 for k in dir (config ):
0 commit comments