Skip to content

Commit

Permalink
Merge pull request #254 from edlerd/support-oidc-login-method
Browse files Browse the repository at this point in the history
ui: set oidc method on login if a provider is present in the values
  • Loading branch information
natalian98 committed Jul 16, 2024
2 parents 361d4e2 + 98f1163 commit 6fd069b
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 6fd069b

Please sign in to comment.