stages/authenticator_validate: add ability to select multiple configuration stages which the user can choose

closes #1843

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2022-02-12 16:55:50 +01:00
parent 9070df6c26
commit 2ccab75021
16 changed files with 346 additions and 102 deletions

View File

@ -67,7 +67,7 @@ export class AuthenticatorValidateStage
return this._selectedDeviceChallenge;
}
submit(payload: AuthenticatorValidationChallengeResponseRequest): Promise<void> {
submit(payload: AuthenticatorValidationChallengeResponseRequest): Promise<boolean> {
return this.host?.submit(payload) || Promise.resolve();
}
@ -140,7 +140,7 @@ export class AuthenticatorValidateStage
}
renderDevicePicker(): TemplateResult {
return html` <ul>
return html`<ul>
${this.challenge?.deviceChallenges.map((challenges) => {
return html`<li>
<button
@ -157,6 +157,30 @@ export class AuthenticatorValidateStage
</ul>`;
}
renderStagePicker(): TemplateResult {
return html`<ul>
${this.challenge?.configurationStages.map((stage) => {
return html`<li>
<button
class="pf-c-button authenticator-button"
type="button"
@click=${() => {
this.submit({
component: this.challenge.component || "",
selectedStage: stage.pk,
});
}}
>
<div class="right">
<p>${stage.name}</p>
<small>${stage.verboseName}</small>
</div>
</button>
</li>`;
})}
</ul>`;
}
renderDeviceChallenge(): TemplateResult {
if (!this.selectedDeviceChallenge) {
return html``;
@ -242,6 +266,9 @@ export class AuthenticatorValidateStage
${this.selectedDeviceChallenge
? ""
: html`<p>${t`Select an authentication method.`}</p>`}
${this.challenge.configurationStages.length > 0
? this.renderStagePicker()
: html``}
</form>
${this.renderDevicePicker()}
</div>