From 75d6cd1674c262eeac30cc1bdf6c89032101fdb9 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 21 May 2022 15:55:19 +0200 Subject: [PATCH] outposts: ensure the user and token are created on initial outpost save Signed-off-by: Jens Langhammer --- authentik/outposts/signals.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/authentik/outposts/signals.py b/authentik/outposts/signals.py index 7a1acba85..2720e82d8 100644 --- a/authentik/outposts/signals.py +++ b/authentik/outposts/signals.py @@ -52,7 +52,7 @@ def m2m_changed_update(sender, instance: Model, action: str, **_): @receiver(post_save) # pylint: disable=unused-argument -def post_save_update(sender, instance: Model, **_): +def post_save_update(sender, instance: Model, created: bool, **_): """If an Outpost is saved, Ensure that token is created/updated If an OutpostModel, or a model that is somehow connected to an OutpostModel is saved, @@ -63,6 +63,9 @@ def post_save_update(sender, instance: Model, **_): return if not isinstance(instance, UPDATE_TRIGGERING_MODELS): return + if isinstance(instance, Outpost) and created: + LOGGER.info("New outpost saved, ensuring initial token and user are created") + _ = instance.token outpost_post_save.delay(class_to_path(instance.__class__), instance.pk)