Skip to content

Commit

Permalink
fix: bugs from passkey PR (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed Jan 12, 2024
1 parent b42fd65 commit 305eb21
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 23 deletions.
4 changes: 0 additions & 4 deletions pages/registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const Registration: NextPage = () => {
returnTo: returnTo ? String(returnTo) : undefined,
})
.then(({ data }) => {
console.log("Created a new registration flow: ", data)
setFlow(data)
})
.catch(handleFlowError(router, "registration", setFlow))
Expand All @@ -60,15 +59,12 @@ const Registration: NextPage = () => {
// his data when she/he reloads the page.
.push(`/registration?flow=${flow?.id}`, undefined, { shallow: true })

console.log("updateRegistrationFlow values", values)
ory
.updateRegistrationFlow({
flow: String(flow?.id),
updateRegistrationFlowBody: values,
})
.then(async ({ data }) => {
console.log("updateRegistrationFlow data", data)

// If we ended up here, it means we are successfully signed up!
//
// You can do cool stuff here, like having access to the identity which just signed up:
Expand Down
2 changes: 1 addition & 1 deletion pages/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ const Settings: NextPage = () => {
flow={flow}
/>
</SettingsCard>
<SettingsCard only="webauthn" flow={flow}>
<SettingsCard only="passkey" flow={flow}>
<H3>Manage Passkeys</H3>
<Messages messages={flow?.ui.messages} />
<Flow
Expand Down
5 changes: 1 addition & 4 deletions pkg/ui/Flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,8 @@ export class Flow<T extends Values> extends Component<Props<T>, State<T>> {
isLoading: true,
}))

console.log("form data", body)
console.log("form data state values", this.state.values)

return this.props
.onSubmit({ ...this.state.values, ...body })
.onSubmit({ ...body, ...this.state.values })
.finally(() => {
// We wait for reconciliation and update the state after 50ms
// Done submitting - update loading status
Expand Down
6 changes: 1 addition & 5 deletions pkg/ui/NodeInputButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { getNodeLabel } from "@ory/integrations/ui"
import { Button } from "@ory/themes"
import { useEffect } from "react"

import { callWebauthnFunction, NodeInputProps, useOnload } from "./helpers"
import { callWebauthnFunction, NodeInputProps } from "./helpers"

export function NodeInputButton<T>({
node,
Expand All @@ -19,7 +18,6 @@ export function NodeInputButton<T>({
//
// Please note that we also need to prevent the default action from happening.
if (attributes.onclick) {
console.log("onclick", attributes.onclick)
e.stopPropagation()
e.preventDefault()
callWebauthnFunction(attributes.onclick)
Expand All @@ -29,8 +27,6 @@ export function NodeInputButton<T>({
setValue(attributes.value).then(() => dispatchSubmit(e))
}

// useOnload(attributes as any)

return (
<>
<Button
Expand Down
10 changes: 1 addition & 9 deletions pkg/ui/NodeInputHidden.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import { useEffect, useRef } from "react"

import { NodeInputProps, useOnload } from "./helpers"

export function NodeInputHidden<T>({ attributes }: NodeInputProps) {
// Render a hidden input field
const inputRef = useRef<HTMLInputElement>(null)

useOnload(attributes as any)

return (
<input
ref={inputRef}
type={attributes.type}
name={attributes.name}
value={
inputRef.current ? inputRef.current?.value : attributes.value || "true"
}
value={attributes.value || "true"}
/>
)
}

0 comments on commit 305eb21

Please sign in to comment.