web/admin: fix authenticatior_valiation stage not setting correct fields

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-06-09 19:38:54 +02:00
parent d4379ecd31
commit 7834146efc

View file

@ -16,13 +16,13 @@ export class AuthenticatorValidateStageForm extends ModelForm<AuthenticatorValid
return new StagesApi(DEFAULT_CONFIG).stagesAuthenticatorValidateRetrieve({ return new StagesApi(DEFAULT_CONFIG).stagesAuthenticatorValidateRetrieve({
stageUuid: pk, stageUuid: pk,
}).then(stage => { }).then(stage => {
this.showConfigureFlow = stage.notConfiguredAction === NotConfiguredActionEnum.Configure; this.showConfigurationStage = stage.notConfiguredAction === NotConfiguredActionEnum.Configure;
return stage; return stage;
}); });
} }
@property({ type: Boolean }) @property({ type: Boolean })
showConfigureFlow = false; showConfigurationStage = true;
getSuccessMessage(): string { getSuccessMessage(): string {
if (this.instance) { if (this.instance) {
@ -74,9 +74,9 @@ export class AuthenticatorValidateStageForm extends ModelForm<AuthenticatorValid
<select class="pf-c-form-control" @change=${(ev: Event) => { <select class="pf-c-form-control" @change=${(ev: Event) => {
const target = ev.target as HTMLSelectElement; const target = ev.target as HTMLSelectElement;
if (target.selectedOptions[0].value === NotConfiguredActionEnum.Configure) { if (target.selectedOptions[0].value === NotConfiguredActionEnum.Configure) {
this.showConfigureFlow = true; this.showConfigurationStage = true;
} else { } else {
this.showConfigureFlow = false; this.showConfigurationStage = false;
} }
}}> }}>
<option value=${NotConfiguredActionEnum.Configure} ?selected=${this.instance?.notConfiguredAction === NotConfiguredActionEnum.Configure}> <option value=${NotConfiguredActionEnum.Configure} ?selected=${this.instance?.notConfiguredAction === NotConfiguredActionEnum.Configure}>
@ -111,24 +111,24 @@ export class AuthenticatorValidateStageForm extends ModelForm<AuthenticatorValid
<p class="pf-c-form__helper-text">${t`Device classes which can be used to authenticate.`}</p> <p class="pf-c-form__helper-text">${t`Device classes which can be used to authenticate.`}</p>
<p class="pf-c-form__helper-text">${t`Hold control/command to select multiple items.`}</p> <p class="pf-c-form__helper-text">${t`Hold control/command to select multiple items.`}</p>
</ak-form-element-horizontal> </ak-form-element-horizontal>
${this.showConfigureFlow ? html` ${this.showConfigurationStage ? html`
<ak-form-element-horizontal <ak-form-element-horizontal
label=${t`Configuration flow`} label=${t`Configuration stage`}
?required=${true} ?required=${true}
name="configureFlow"> name="configurationStage">
<select class="pf-c-form-control"> <select class="pf-c-form-control">
<option value="" ?selected=${this.instance?.configurationStage === undefined}>---------</option> <option value="" ?selected=${this.instance?.configurationStage === undefined}>---------</option>
${until(new StagesApi(DEFAULT_CONFIG).stagesAllList({ ${until(new StagesApi(DEFAULT_CONFIG).stagesAllList({
ordering: "pk", ordering: "pk",
}).then(stages => { }).then(stages => {
return stages.results.map(stage => { return stages.results.map(stage => {
const selected = this.instance?.configurationStage === stage.pk; const selected = this.instance?.configurationStage === stage.pk;
return html`<option value=${ifDefined(stage.pk)} ?selected=${selected}>${stage.name} (${stage.verboseName})</option>`; return html`<option value=${ifDefined(stage.pk)} ?selected=${selected}>${stage.name} (${stage.verboseName})</option>`;
}); });
}), html`<option>${t`Loading...`}</option>`)} }), html`<option>${t`Loading...`}</option>`)}
</select> </select>
<p class="pf-c-form__helper-text">${t`Stage used to configure Authenticator when user doesn't have any compatible devices. After this configuration Stage passes, the user is not prompted again.`}</p> <p class="pf-c-form__helper-text">${t`Stage used to configure Authenticator when user doesn't have any compatible devices. After this configuration Stage passes, the user is not prompted again.`}</p>
</ak-form-element-horizontal> </ak-form-element-horizontal>
`: html``} `: html``}
</div> </div>
</ak-form-group> </ak-form-group>