Add signal for new OAuth applications

This commit is contained in:
Raphael Michel
2018-06-05 15:35:45 +02:00
parent b40100f78b
commit b4d97d9432
3 changed files with 12 additions and 1 deletions

View File

@@ -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.
"""

View File

@@ -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)