From f1afc4d2638c91bb51d41db306c3470daa6cfe29 Mon Sep 17 00:00:00 2001 From: Jens L Date: Thu, 2 May 2024 19:54:21 +0200 Subject: [PATCH] web/flows: fix error when enrolling multiple WebAuthn devices consecutively (#9545) Signed-off-by: Jens Langhammer --- .../WebAuthnAuthenticatorRegisterStage.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/web/src/flow/stages/authenticator_webauthn/WebAuthnAuthenticatorRegisterStage.ts b/web/src/flow/stages/authenticator_webauthn/WebAuthnAuthenticatorRegisterStage.ts index ae809bbb6e..b2eb9e12c3 100644 --- a/web/src/flow/stages/authenticator_webauthn/WebAuthnAuthenticatorRegisterStage.ts +++ b/web/src/flow/stages/authenticator_webauthn/WebAuthnAuthenticatorRegisterStage.ts @@ -8,7 +8,7 @@ import "@goauthentik/elements/EmptyState"; import { BaseStage } from "@goauthentik/flow/stages/base"; import { msg, str } from "@lit/localize"; -import { CSSResult, TemplateResult, css, html, nothing } from "lit"; +import { CSSResult, PropertyValues, TemplateResult, css, html, nothing } from "lit"; import { customElement, property } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; @@ -115,14 +115,16 @@ export class WebAuthnAuthenticatorRegisterStage extends BaseStage< }); } - firstUpdated(): void { - // convert certain members of the PublicKeyCredentialCreateOptions into - // byte arrays as expected by the spec. - this.publicKeyCredentialCreateOptions = transformCredentialCreateOptions( - this.challenge?.registration as PublicKeyCredentialCreationOptions, - this.challenge?.registration.user.id, - ); - this.registerWrapper(); + updated(changedProperties: PropertyValues) { + if (changedProperties.has("challenge") && this.challenge !== undefined) { + // convert certain members of the PublicKeyCredentialCreateOptions into + // byte arrays as expected by the spec. + this.publicKeyCredentialCreateOptions = transformCredentialCreateOptions( + this.challenge?.registration as PublicKeyCredentialCreationOptions, + this.challenge?.registration.user.id, + ); + this.registerWrapper(); + } } render(): TemplateResult {