From c3faa61ed9f34424793577405768d474f2c7290a Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 8 Nov 2021 14:47:50 +0100 Subject: [PATCH] stages/prompt: set field placeholder based on plan context Signed-off-by: Jens Langhammer --- authentik/stages/prompt/stage.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/authentik/stages/prompt/stage.py b/authentik/stages/prompt/stage.py index 5ff8ac7e5..2b4d2430b 100644 --- a/authentik/stages/prompt/stage.py +++ b/authentik/stages/prompt/stage.py @@ -164,10 +164,16 @@ class PromptStageView(ChallengeStageView): def get_challenge(self, *args, **kwargs) -> Challenge: fields = list(self.executor.current_stage.fields.all().order_by("order")) + serializers = [] + context_prompt = self.executor.plan.get(PLAN_CONTEXT_PROMPT, {}) + for field in fields: + data = StagePromptSerializer(field).data + data["placeholder"] = context_prompt.get(field.field_key) + serializers.append(data) challenge = PromptChallenge( data={ "type": ChallengeTypes.NATIVE.value, - "fields": [StagePromptSerializer(field).data for field in fields], + "fields": serializers, }, ) return challenge