Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: passkey and webauthn in settings flow #317

Merged
merged 1 commit into from
Dec 17, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,21 @@
)
}

const getScriptNode = (nodes: UiNode[]): UiNode | undefined =>
nodes.find(
(node) =>

Check warning on line 108 in packages/elements-react/src/components/settings/settings-card.tsx

View check run for this annotation

Codecov / codecov/patch

packages/elements-react/src/components/settings/settings-card.tsx#L106-L108

Added lines #L106 - L108 were not covered by tests
"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)

Check warning on line 115 in packages/elements-react/src/components/settings/settings-card.tsx

View check run for this annotation

Codecov / codecov/patch

packages/elements-react/src/components/settings/settings-card.tsx#L115

Added line #L115 was not covered by tests

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
Loading