Skip to content

Commit

Permalink
fix: passkey and webauthn in settings flow (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr authored Dec 17, 2024
1 parent 49d5de1 commit d5af551
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,21 @@ function SettingsSectionContent({ group, nodes }: SettingsSectionProps) {
)
}

const getScriptNode = (nodes: UiNode[]): UiNode | undefined =>
nodes.find(
(node) =>
"id" in node.attributes && node.attributes.id === "webauthn_script",
)

export function OrySettingsCard() {
const { flow } = useOryFlow()
const uniqueGroups = useNodesGroups(flow.ui.nodes)
const scriptNode = getScriptNode(flow.ui.nodes)

return (
<>
<OryCardValidationMessages />
{scriptNode && <Node node={scriptNode} />}
{uniqueGroups.entries.map(([group, nodes]) => {
if (group === UiNodeGroupEnum.Default) {
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ const getRemoveButtons = (nodes: UiNode[]): UiNode[] =>
"name" in node.attributes && node.attributes.name === "webauthn_remove",
)

const getScriptNode = (nodes: UiNode[]): UiNode | undefined =>
nodes.find(
(node) =>
"id" in node.attributes && node.attributes.id === "webauthn_script",
)

const getRegisterNode = (nodes: UiNode[]): UiNode | undefined =>
nodes.find(
(node) =>
Expand All @@ -56,7 +50,6 @@ export function OrySettingsWebauthn({ nodes }: HeadlessSettingsWebauthnProps) {
const triggerButton = getTriggerNode(nodes)
const inputNode = getInputNode(nodes)
const removeButtons = getRemoveButtons(nodes)
const scriptNode = getScriptNode(nodes)
const registerNode = getRegisterNode(nodes)

if (!inputNode || !triggerButton) {
Expand Down Expand Up @@ -84,8 +77,6 @@ export function OrySettingsWebauthn({ nodes }: HeadlessSettingsWebauthnProps) {
{groups.default?.map((node, i) => (
<Node key={`webauthn-default-${i}`} node={node} />
))}
{scriptNode && <Node node={scriptNode} />}
{registerNode && <Node node={registerNode} />}
<Form.WebauthnSettings
nameInput={inputNode}
triggerButton={{
Expand All @@ -95,6 +86,7 @@ export function OrySettingsWebauthn({ nodes }: HeadlessSettingsWebauthnProps) {
}}
removeButtons={removeButtons}
/>
{registerNode && <Node node={registerNode} />}
</Card.SettingsSectionContent>
<Card.SettingsSectionFooter>
<span>{intl.formatMessage({ id: "settings.webauthn.info" })}</span>
Expand Down

0 comments on commit d5af551

Please sign in to comment.