Skip to content

Commit 4e443c1

Browse files
committed
Hotfix
1 parent 7c27be5 commit 4e443c1

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

pkg/errors.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ import { NextRouter } from "next/router"
33
import { Dispatch, SetStateAction } from "react"
44
import { toast } from "react-toastify"
55

6+
7+
function handleAal2Error(jsonResponse: any, router: NextRouter,) {
8+
if (jsonResponse.error?.id === "session_aal2_required") {
9+
window.location.href = "/auth/login?aal=aal2"
10+
}
11+
else router.push("/cognition")
12+
13+
}
14+
15+
616
// A small function to help us deal with errors coming from fetching a flow.
717
export function handleGetFlowError<S>(
818
router: NextRouter,
@@ -16,6 +26,10 @@ export function handleGetFlowError<S>(
1626
window.location.href = (err.response?.data as any).redirect_browser_to
1727
return
1828
case "session_already_available":
29+
await fetch('/.ory/kratos/public/sessions/whoami')
30+
.then(response => response.json())
31+
.then((jsonResponse) => handleAal2Error(jsonResponse, router))
32+
.catch(() => { router.push("/cognition") });
1933
// User is already signed in, let's redirect them home!
2034
await router.push("/cognition")
2135
return

0 commit comments

Comments
 (0)