Skip to content

Commit

Permalink
fix: missing settings screen webauthn handler (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik authored Sep 7, 2023
1 parent f62260a commit 0afcf82
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/routes/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import {
RouteCreator,
RouteRegistrator,
} from "../pkg"
import { UiNodeInputAttributes } from "@ory/client"
import { UserSettingsScreen } from "@ory/elements-markup"
import {
filterNodesByGroups,
isUiNodeInputAttributes,
} from "@ory/integrations/ui"

export const createSettingsRoute: RouteCreator =
(createHelpers) => async (req, res, next) => {
Expand Down Expand Up @@ -67,6 +72,18 @@ export const createSettingsRoute: RouteCreator =
nodes: flow.ui.nodes,
nav: settingsScreen.Nav,
settingsScreen: settingsScreen.Body,
webAuthnHandler: filterNodesByGroups({
nodes: flow.ui.nodes,
groups: ["webauthn"],
attributes: ["button"],
withoutDefaultAttributes: true,
withoutDefaultGroup: true,
})
.filter(({ attributes }) => isUiNodeInputAttributes(attributes))
.map(({ attributes }) => {
return (attributes as UiNodeInputAttributes).onclick
})
.filter((c) => c !== undefined),
})
})
.catch(redirectOnSoftError(res, next, initFlowUrl))
Expand Down
2 changes: 0 additions & 2 deletions views/partials/webauthn_setup.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

<script type="text/javascript">
document.getElementsByName("{{webauthnTriggerName}}").forEach((v) => {
console.log("attaching event listener")
v.addEventListener("click", () => {
console.log("clicked");
{{{webAuthnHandler}}}
})
})
Expand Down

0 comments on commit 0afcf82

Please sign in to comment.