From 5f90f5419572689276bba32bdc9ad49bfe2b6801 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 24 Dec 2020 16:47:21 +0100 Subject: [PATCH] stages/invitation: ensure created_by is set when creating from API --- authentik/stages/invitation/api.py | 4 ++++ .../migrations/0003_auto_20201227_1210.py | 22 +++++++++++++++++++ swagger.yaml | 1 - 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 authentik/stages/invitation/migrations/0003_auto_20201227_1210.py diff --git a/authentik/stages/invitation/api.py b/authentik/stages/invitation/api.py index f1390abe2..9a4402453 100644 --- a/authentik/stages/invitation/api.py +++ b/authentik/stages/invitation/api.py @@ -43,3 +43,7 @@ class InvitationViewSet(ModelViewSet): queryset = Invitation.objects.all() serializer_class = InvitationSerializer + + def perform_create(self, serializer: InvitationSerializer): + serializer.instance.created_by = self.request.user + return super().perform_create(serializer) diff --git a/authentik/stages/invitation/migrations/0003_auto_20201227_1210.py b/authentik/stages/invitation/migrations/0003_auto_20201227_1210.py new file mode 100644 index 000000000..ea973ed59 --- /dev/null +++ b/authentik/stages/invitation/migrations/0003_auto_20201227_1210.py @@ -0,0 +1,22 @@ +# Generated by Django 3.1.4 on 2020-12-27 12:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("authentik_stages_invitation", "0002_auto_20201225_2143"), + ] + + operations = [ + migrations.AlterField( + model_name="invitation", + name="fixed_data", + field=models.JSONField( + blank=True, + default=dict, + help_text="Optional fixed data to enforce on user enrollment.", + ), + ), + ] diff --git a/swagger.yaml b/swagger.yaml index d26429144..306362579 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -7003,7 +7003,6 @@ definitions: - suspicious_request - password_set - token_view - - invitation_created - invitation_used - authorize_application - source_linked