From 4e443c199418d12707f16e8100177aad83584ce6 Mon Sep 17 00:00:00 2001 From: JWittmeyer Date: Fri, 18 Oct 2024 11:02:28 +0200 Subject: [PATCH] Hotfix --- pkg/errors.tsx | 14 ++++++++++++++ submodules/javascript-functions | 2 +- submodules/react-components | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/errors.tsx b/pkg/errors.tsx index 5942d66..b73ff66 100644 --- a/pkg/errors.tsx +++ b/pkg/errors.tsx @@ -3,6 +3,16 @@ import { NextRouter } from "next/router" import { Dispatch, SetStateAction } from "react" import { toast } from "react-toastify" + +function handleAal2Error(jsonResponse: any, router: NextRouter,) { + if (jsonResponse.error?.id === "session_aal2_required") { + window.location.href = "/auth/login?aal=aal2" + } + else router.push("/cognition") + +} + + // A small function to help us deal with errors coming from fetching a flow. export function handleGetFlowError( router: NextRouter, @@ -16,6 +26,10 @@ export function handleGetFlowError( window.location.href = (err.response?.data as any).redirect_browser_to return case "session_already_available": + await fetch('/.ory/kratos/public/sessions/whoami') + .then(response => response.json()) + .then((jsonResponse) => handleAal2Error(jsonResponse, router)) + .catch(() => { router.push("/cognition") }); // User is already signed in, let's redirect them home! await router.push("/cognition") return diff --git a/submodules/javascript-functions b/submodules/javascript-functions index a247950..75fa5a5 160000 --- a/submodules/javascript-functions +++ b/submodules/javascript-functions @@ -1 +1 @@ -Subproject commit a2479502cb59b9ed1f6fd5f5ce6fc084f22d270d +Subproject commit 75fa5a525c8a114cd6a4a0395a27be69a985f46e diff --git a/submodules/react-components b/submodules/react-components index 42f1af8..1577856 160000 --- a/submodules/react-components +++ b/submodules/react-components @@ -1 +1 @@ -Subproject commit 42f1af8d2534bd1c82094fce4cc70d193344cfb8 +Subproject commit 1577856a614772f50ec817075f7bd52e6f1a4204