Skip to content

Commit 625e98f

Browse files
jkcgsclaudep
authored andcommitted
WebAuthn: Avoid submitting the wrong form
If the template is modified/overridden, there could be other forms before the two-factor one. This selects the form based on the tokenField input.
1 parent 227bb96 commit 625e98f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

two_factor/plugins/webauthn/templates/two_factor_webauthn/create_credential.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ navigator.credentials.create({
2020
type: attestationCredential.type,
2121
},
2222
tokenField = document.querySelector('[name=webauthn-token]'),
23-
form = document.forms[0];
23+
form = tokenField.closest('form');
2424

2525
tokenField.value = JSON.stringify(serializableAttestationCredential);
2626
form.submit();

0 commit comments

Comments
 (0)