Skip to content

Commit

Permalink
chore: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Benehiko committed Oct 5, 2023
1 parent 6afcf57 commit e7bf6a5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
13 changes: 9 additions & 4 deletions examples/nextjs-spa/src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ const Login: NextPageWithLayout = () => {
)

const createFlow = useCallback(
(refresh: boolean, aal: string, returnTo: string, loginChallenge?: string) =>
(
refresh: boolean,
aal: string,
returnTo: string,
loginChallenge?: string,
) =>
ory
.createBrowserLoginFlow({
refresh: refresh,
Expand Down Expand Up @@ -123,12 +128,12 @@ const Login: NextPageWithLayout = () => {
includeScripts={true}
// we submit the form data to Ory
onSubmit={({ body }) => submitFlow(body as UpdateLoginFlowBody)}

// OAauth2 and OpenID Connect
{...(flow.oauth2_login_request && {
subtitle: `To authenticate ${flow.oauth2_login_request.client?.client_name ||
subtitle: `To authenticate ${
flow.oauth2_login_request.client?.client_name ||
flow.oauth2_login_request.client?.client_id
}`
}`,
})}
/>
) : (
Expand Down
9 changes: 5 additions & 4 deletions src/react-components/ory/helpers/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export function CustomOnSubmit<Type>(
if (isString(objValue) && isString(srcValue)) {
return [objValue, srcValue]
} else if (isArray(objValue) && isString(srcValue)) {
return objValue.concat(srcValue)
objValue.push(srcValue)
return objValue as string[]
}
},
)
Expand All @@ -82,12 +83,12 @@ export function CustomOnSubmit<Type>(
event.nativeEvent as unknown as { submitter: HTMLInputElement }
).submitter
body = {
...(body as Type),
...body,
...{ [method.name]: method.value },
}
}

callback && callback({ body: body as Type, event })
callback && callback({ body: body, event })

return body as Type
return body
}
6 changes: 3 additions & 3 deletions src/react-components/ory/helpers/user-auth-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export type UpdateBody =
| UpdateVerificationFlowBody
| UpdateSettingsFlowBody

export interface UserAuthFormAdditionalProps = {
onSubmit ?: CustomOnSubmitCallback<UpdateBody>
export interface UserAuthFormAdditionalProps {
onSubmit?: CustomOnSubmitCallback<UpdateBody>
}

/**
Expand All @@ -43,7 +43,7 @@ export interface UserAuthFormAdditionalProps = {
*/
export interface UserAuthFormProps
extends Omit<React.FormHTMLAttributes<HTMLFormElement>, "onSubmit">,
UserAuthFormAdditionalProps {
UserAuthFormAdditionalProps {
flow: SelfServiceFlow
children: React.ReactNode
formFilterOverride?: FilterNodesByGroups
Expand Down

0 comments on commit e7bf6a5

Please sign in to comment.