From 314ce40e712685537fc6cc8f3430f00073cc1571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 10 Oct 2018 15:30:35 +0200 Subject: [PATCH] Send logged-in user in user_authenticated signal --- pillar/api/utils/authentication.py | 2 +- pillar/auth/__init__.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pillar/api/utils/authentication.py b/pillar/api/utils/authentication.py index 3940b621..8f153eb2 100644 --- a/pillar/api/utils/authentication.py +++ b/pillar/api/utils/authentication.py @@ -189,7 +189,7 @@ def validate_this_token(token, oauth_subclient=None): return None g.current_user = UserClass.construct(token, db_user) - user_authenticated.send(None) + user_authenticated.send(sender=g.current_user) return db_user diff --git a/pillar/auth/__init__.py b/pillar/auth/__init__.py index 14ee63ff..9f13b690 100644 --- a/pillar/auth/__init__.py +++ b/pillar/auth/__init__.py @@ -12,7 +12,9 @@ from werkzeug.local import LocalProxy from pillar import current_app +# The sender is the user that was just authenticated. user_authenticated = blinker.Signal('Sent whenever a user was authenticated') + log = logging.getLogger(__name__) # Mapping from user role to capabilities obtained by users with that role. @@ -225,7 +227,7 @@ def login_user_object(user: UserClass): """Log in the given user.""" flask_login.login_user(user, remember=True) g.current_user = user - user_authenticated.send(None) + user_authenticated.send(sender=user) def logout_user():