Skip to content

Commit

Permalink
[data] Fix WebAuthn Authenticate (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
horus committed Mar 19, 2023
1 parent b622a6d commit d3836c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions src/data/webAuthnAuthenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type DataType = {

type RefsType = {
authenticatorDataInput: HTMLInputElement;
authnSelectForm: HTMLFormElement;
authnSelectForm?: HTMLFormElement;
clientDataJSONInput: HTMLInputElement;
credentialIdInput: HTMLInputElement;
errorInput: HTMLInputElement;
Expand Down Expand Up @@ -114,17 +114,19 @@ document.addEventListener('alpine:init', () => {
const checkAllowCredentials = () => {
const allowCredentials: PublicKeyCredentialDescriptor[] = [];

const authnSelectFormElements = Array.from(authnSelectForm.elements);
if (authnSelectForm) {
const authnSelectFormElements = Array.from(authnSelectForm.elements);

if (authnSelectFormElements.length) {
authnSelectFormElements.forEach((element) => {
if (element instanceof HTMLInputElement) {
allowCredentials.push({
id: base64url.parse(element.value, { loose: true }),
type: 'public-key',
});
}
});
if (authnSelectFormElements.length) {
authnSelectFormElements.forEach((element) => {
if (element instanceof HTMLInputElement) {
allowCredentials.push({
id: base64url.parse(element.value, { loose: true }),
type: 'public-key',
});
}
});
}
}

doAuthenticate(allowCredentials);
Expand Down
2 changes: 1 addition & 1 deletion theme/keywind/login/resources/dist/webAuthnAuthenticate.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d3836c0

Please sign in to comment.