Skip to content

Commit

Permalink
fix: separate the oidc login controls from email password
Browse files Browse the repository at this point in the history
  • Loading branch information
mainawycliffe committed Nov 17, 2023
1 parent 54b1477 commit e68010c
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 35 deletions.
116 changes: 81 additions & 35 deletions src/components/ory/ui/Flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import {
UpdateVerificationFlowBody as SubmitSelfServiceVerificationFlowBody,
UiNode
} from "@ory/client";
import { getNodeId, isUiNodeInputAttributes } from "@ory/integrations/ui";
import {
filterNodesByGroups,
getNodeId,
isUiNodeInputAttributes
} from "@ory/integrations/ui";
import { Component, FormEvent } from "react";

import FormSkeletonLoader from "../../SkeletonLoader/FormSkeletonLoader";
Expand Down Expand Up @@ -158,40 +162,82 @@ export class Flow<T extends Values> extends Component<Props<T>, State<T>> {
}

return (
<form
className="space-y-8"
action={flow.ui.action}
method={flow.ui.method}
onSubmit={this.handleSubmit}
>
{!hideGlobalMessages ? <Messages messages={flow.ui.messages} /> : null}
{nodes.map((node, k) => {
const id = getNodeId(node) as keyof Values;
return (
<Node
key={`${id}-${k}`}
disabled={isLoading}
node={node}
value={values[id]}
dispatchSubmit={this.handleSubmit}
setValue={(value) =>
new Promise((resolve) => {
this.setState(
(state) => ({
...state,
values: {
...state.values,
[getNodeId(node)]: value
}
}),
resolve
);
})
}
/>
);
})}
</form>
<div className="flex flex-col gap-2">
<form
className="space-y-8"
action={flow.ui.action}
method={flow.ui.method}
onSubmit={this.handleSubmit}
>
{!hideGlobalMessages ? (
<Messages messages={flow.ui.messages} />
) : null}
{filterNodesByGroups({
nodes: nodes,
groups: ["default", "password"]
}).map((node, k) => {
const id = getNodeId(node) as keyof Values;
return (
<Node
key={`${id}-${k}`}
disabled={isLoading}
node={node}
value={values[id]}
dispatchSubmit={this.handleSubmit}
setValue={(value) =>
new Promise((resolve) => {
this.setState(
(state) => ({
...state,
values: {
...state.values,
[getNodeId(node)]: value
}
}),
resolve
);
})
}
/>
);
})}
</form>

<hr className="border-gray-200 my-3" />

<div className="flex flex-col">
{filterNodesByGroups({
nodes: nodes,
groups: ["oidc", "webauthn"],
withoutDefaultGroup: true
}).map((node, k) => {
const id = getNodeId(node) as keyof Values;
return (
<Node
key={`${id}-${k}`}
disabled={isLoading}
node={node}
value={values[id]}
dispatchSubmit={this.handleSubmit}
setValue={(value) =>
new Promise((resolve) => {
this.setState(
(state) => ({
...state,
values: {
...state.values,
[getNodeId(node)]: value
}
}),
resolve
);
})
}
/>
);
})}
</div>
</div>
);
}
}
1 change: 1 addition & 0 deletions src/components/ory/ui/NodeInputButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function NodeInputButton({
}}
value={attributes.value || ""}
disabled={attributes.disabled || disabled}
type="button"
>
{getNodeLabel(node)}
</button>
Expand Down
1 change: 1 addition & 0 deletions src/components/ory/ui/NodeInputSubmit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function NodeInputSubmit({
}}
value={attributes.value || ""}
disabled={attributes.disabled || disabled}
type="submit"
>
{getNodeLabel(node)}
</button>
Expand Down

0 comments on commit e68010c

Please sign in to comment.