Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions app/javascript/packs/webauthn-authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ function webauthn() {
const webauthnSuccessContainer = document.getElementById('webauthn-auth-successful')!;

const webauthAlertContainer = document.querySelector('.usa-alert--error')!;
const webauthnPlatformRequested =
webauthnInProgressContainer.dataset.platformAuthenticatorRequested === 'true';
Comment on lines -9 to -10
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation for the fix:

This data- property was removed in #8723, and was meant to be substituted by hard-coding the value into the form...


const spinner = document.getElementById('spinner')!;
spinner.classList.remove('display-none');
Expand Down Expand Up @@ -41,8 +39,6 @@ function webauthn() {
})
.catch((error: Error) => {
(document.getElementById('webauthn_error') as HTMLInputElement).value = error.name;
(document.getElementById('platform') as HTMLInputElement).value =
String(webauthnPlatformRequested);
Comment on lines -44 to -45
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...but since we were still assigning a value here from the non-existent data- attribute, the form value was being overridden.

The solution is to just not set the value when the error happens, so that the form value remains undisturbed.

(document.getElementById('webauthn_form') as HTMLFormElement).submit();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<%= hidden_field_tag :signature, '', id: 'signature' %>
<%= hidden_field_tag :client_data_json, '', id: 'client_data_json' %>
<%= hidden_field_tag :webauthn_error, '', id: 'webauthn_error' %>
<%= hidden_field_tag :platform, @presenter.platform_authenticator?, id: 'platform' %>
<%= hidden_field_tag :platform, @presenter.platform_authenticator? %>

<%= content_tag(
:div,
Expand Down