Skip to content

Commit

Permalink
fix(ui) unpack values received from kratos (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
edlerd authored Jun 23, 2023
1 parent 2efa02e commit 3e59436
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ui/pages/error.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FlowError } from "@ory/client";
import { Notification, Row } from "@canonical/react-components";
import { AxiosError } from "axios";
import { AxiosError, AxiosResponse } from "axios";
import type { NextPage } from "next";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
Expand All @@ -23,7 +23,7 @@ const Error: NextPage = () => {

kratos
.getFlowError({ id: String(id) })
.then(void setError)
.then((res: AxiosResponse<FlowError>) => setError(res.data))
.catch((err: AxiosError) => {
switch (err.response?.status) {
case 404:
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Home: NextPage = () => {
useEffect(() => {
kratos
.toSession()
.then(void setSession)
.then((res) => setSession(res.data))
.catch((err: AxiosError) => {
switch (err.response?.status) {
case 403:
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Login: NextPage = () => {
if (flowId) {
kratos
.getLoginFlow({ id: String(flowId) })
.then(void setFlow)
.then((res) => setFlow(res.data))
.catch(handleFlowError(router, "login", setFlow));
return;
}
Expand Down
4 changes: 3 additions & 1 deletion ui/pages/registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ const Registration: NextPage = () => {
flow: String(flow?.id),
updateRegistrationFlowBody: values,
})
.then(() => void router.push(flow?.return_to ?? "/"))
.then(async () => {
await router.push(flow?.return_to ?? "/");
})
.catch(handleFlowError(router, "registration", setFlow))
.catch((err: AxiosError<LoginFlow>) => {
// If the previous handler did not catch the error it's most likely a form validation error
Expand Down

0 comments on commit 3e59436

Please sign in to comment.