flows: handle flow title formatting error better, add user to flow title context

This commit is contained in:
Jens Langhammer 2022-04-14 13:56:20 +00:00
parent 6f0fa731c0
commit 8242b09394
1 changed files with 28 additions and 21 deletions

View File

@ -120,9 +120,12 @@ class ChallengeStageView(StageView):
return self.executor.flow.title
try:
return self.executor.flow.title % {
"app": self.executor.plan.context.get(PLAN_CONTEXT_APPLICATION, "")
"app": self.executor.plan.context.get(PLAN_CONTEXT_APPLICATION, ""),
"user": self.get_pending_user(for_display=True),
}
except ValueError:
# pylint: disable=broad-except
except Exception as exc:
LOGGER.warning("failed to template title", exc=exc)
return self.executor.flow.title
def _get_challenge(self, *args, **kwargs) -> Challenge:
@ -131,6 +134,10 @@ class ChallengeStageView(StageView):
description=self.__class__.__name__,
):
challenge = self.get_challenge(*args, **kwargs)
with Hub.current.start_span(
op="authentik.flow.stage._get_challenge",
description=self.__class__.__name__,
):
if "flow_info" not in challenge.initial_data:
flow_info = ContextualFlowInfo(
data={