Skip to content

Commit

Permalink
ui: set oidc method on login if a provider is present in the values
Browse files Browse the repository at this point in the history
Signed-off-by: David Edler <[email protected]>
  • Loading branch information
edlerd authored and natalian98 committed Jul 16, 2024
1 parent 361d4e2 commit 98f1163
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ui/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { kratos } from "../api/kratos";
import { FlowResponse } from "./consent";
import PageLayout from "../components/PageLayout";
import { replaceAuthLabel } from "../util/replaceAuthLabel";
import { UpdateLoginFlowWithOidcMethod } from "@ory/client/api";

const Login: NextPage = () => {
const [flow, setFlow] = useState<LoginFlow>();
Expand Down Expand Up @@ -73,12 +74,22 @@ const Login: NextPage = () => {
]);
const handleSubmit = useCallback(
(values: UpdateLoginFlowBody) => {
const getMethod = () => {
if ((values as UpdateLoginFlowWithOidcMethod).provider) {
return "oidc";
}
if (isAuthCode) {
return "totp";
}
return "password";
};

return kratos
.updateLoginFlow({
flow: String(flow?.id),
updateLoginFlowBody: {
...values,
method: isAuthCode ? "totp" : "password",
method: getMethod(),
} as UpdateLoginFlowBody,
})
.then(({ data }) => {
Expand Down

0 comments on commit 98f1163

Please sign in to comment.