flows/stages/consent: fix for post requests (#3339)

add unique token to consent stage to ensure it is shown

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens L
2022-07-31 23:47:40 +02:00
committed by GitHub
parent 475019202b
commit 553989d17f
5 changed files with 51 additions and 14 deletions

View File

@ -23,17 +23,19 @@ export function readFileAsync(file: Blob) {
});
}
export type KeyUnknown = {
[key: string]: unknown;
};
export class BaseStage<Tin, Tout> extends LitElement {
host!: StageHost;
@property({ attribute: false })
challenge!: Tin;
async submitForm(e: Event): Promise<boolean> {
async submitForm(e: Event, defaults?: KeyUnknown): Promise<boolean> {
e.preventDefault();
const object: {
[key: string]: unknown;
} = {};
const object: KeyUnknown = defaults || {};
const form = new FormData(this.shadowRoot?.querySelector("form") || undefined);
for await (const [key, value] of form.entries()) {

View File

@ -107,7 +107,9 @@ export class ConsentStage extends BaseStage<ConsentChallenge, ConsentChallengeRe
<form
class="pf-c-form"
@submit=${(e: Event) => {
this.submitForm(e);
this.submitForm(e, {
token: this.challenge.token,
});
}}
>
<ak-form-static