From b9a9da4ec7031f009c8ccf2871a1ff511ac0dfdc Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 27 Feb 2021 21:04:19 +0100 Subject: [PATCH] web/stages/prompt: render later so fields aren't cached --- web/src/elements/stages/prompt/PromptStage.ts | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/web/src/elements/stages/prompt/PromptStage.ts b/web/src/elements/stages/prompt/PromptStage.ts index fa0a27611..22d4455e9 100644 --- a/web/src/elements/stages/prompt/PromptStage.ts +++ b/web/src/elements/stages/prompt/PromptStage.ts @@ -1,5 +1,6 @@ import { gettext } from "django"; import { CSSResult, customElement, html, property, TemplateResult } from "lit-element"; +import { unsafeHTML } from "lit-html/directives/unsafe-html"; import { Challenge } from "../../../api/Flows"; import { COMMON_STYLES } from "../../../common/styles"; import { BaseStage } from "../base"; @@ -28,10 +29,10 @@ export class PromptStage extends BaseStage { return COMMON_STYLES; } - renderPromptInner(prompt: Prompt): TemplateResult { + renderPromptInner(prompt: Prompt): string { switch (prompt.type) { case "text": - return html``; case "username": - return html``; case "email": - return html``; case "password": - return html``; case "number": - return html``; case "checkbox": - return html``; case "date": - return html``; case "date-time": - return html``; case "separator": - return html`
`; + return "
"; case "hidden": - return html``; case "static": - return html`

${prompt.placeholder}

`; } - return html``; + return ""; } render(): TemplateResult { @@ -126,7 +127,7 @@ export class PromptStage extends BaseStage { ?required="${prompt.required}" class="pf-c-form__group" .errors=${(this.challenge?.response_errors || {})[prompt.field_key]}> - ${this.renderPromptInner(prompt)} + ${unsafeHTML(this.renderPromptInner(prompt))} `; })}