From b4d97d94321a2fa7f499b67b15178ccbe81dfb0d Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 5 Jun 2018 15:35:45 +0200 Subject: [PATCH] Add signal for new OAuth applications --- doc/development/api/general.rst | 2 +- src/pretix/control/signals.py | 7 +++++++ src/pretix/control/views/oauth.py | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/development/api/general.rst b/doc/development/api/general.rst index caeeae3d1f..ace8d7307b 100644 --- a/doc/development/api/general.rst +++ b/doc/development/api/general.rst @@ -48,7 +48,7 @@ Backend ------- .. automodule:: pretix.control.signals - :members: nav_event, html_head, quota_detail_html, nav_topbar, nav_global, nav_organizer, nav_event_settings, order_info, event_settings_widget + :members: nav_event, html_head, quota_detail_html, nav_topbar, nav_global, nav_organizer, nav_event_settings, order_info, event_settings_widget, oauth_application_registered .. automodule:: pretix.base.signals diff --git a/src/pretix/control/signals.py b/src/pretix/control/signals.py index dfa3c1419f..c6d7761c50 100644 --- a/src/pretix/control/signals.py +++ b/src/pretix/control/signals.py @@ -232,3 +232,10 @@ styles. It is advisable to set a prefix for your form to avoid clashes with othe As with all plugin signals, the ``sender`` keyword argument will contain the event. """ + +oauth_application_registered = Signal( + providing_args=["user", "application"] +) +""" +This signal will be called whenever a user registers a new OAuth application. +""" diff --git a/src/pretix/control/views/oauth.py b/src/pretix/control/views/oauth.py index 02877f1f89..73a53759a8 100644 --- a/src/pretix/control/views/oauth.py +++ b/src/pretix/control/views/oauth.py @@ -18,6 +18,7 @@ from oauth2_provider.views import ( from pretix.api.models import ( OAuthAccessToken, OAuthApplication, OAuthRefreshToken, ) +from pretix.control.signals import oauth_application_registered logger = logging.getLogger(__name__) @@ -43,6 +44,9 @@ class OAuthApplicationRegistrationView(ApplicationRegistration): def form_valid(self, form): form.instance.client_type = 'confidential' form.instance.authorization_grant_type = 'authorization-code' + oauth_application_registered.send( + sender=self.request, user=self.request.user, application=form.instance + ) return super().form_valid(form)