From 51291069f4fe5c51501a39bbe9bc2ac4d59c0fb2 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Tue, 18 Mar 2025 19:41:30 +0545 Subject: [PATCH 1/2] fix(kratos): redirect after login --- .../Authentication/Kratos/KratosAuthSessionChecker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Authentication/Kratos/KratosAuthSessionChecker.tsx b/src/components/Authentication/Kratos/KratosAuthSessionChecker.tsx index 2e1d47f99..c8b13a23f 100644 --- a/src/components/Authentication/Kratos/KratosAuthSessionChecker.tsx +++ b/src/components/Authentication/Kratos/KratosAuthSessionChecker.tsx @@ -27,7 +27,7 @@ export default function KratosAuthSessionChecker({ const { data } = await ory.toSession(); setSession(data); } catch (err) { - const url = window.location.pathname; + const url = encodeURIComponent(window.location.href); switch ((err as AxiosError).response?.status) { case 403: push(`/login?aal=aal2&return_to=${url}`); From 64d4d5ee415b059aee18e3eeb9fd1d84ea4b3e75 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Tue, 18 Mar 2025 19:45:29 +0545 Subject: [PATCH 2/2] fix(clerk): redirect_to --- src/components/Authentication/Clerk/ClerkLogin.tsx | 6 ++---- src/components/Authentication/Clerk/ClerkRegistration.tsx | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/Authentication/Clerk/ClerkLogin.tsx b/src/components/Authentication/Clerk/ClerkLogin.tsx index f2a8d782c..261b18931 100644 --- a/src/components/Authentication/Clerk/ClerkLogin.tsx +++ b/src/components/Authentication/Clerk/ClerkLogin.tsx @@ -4,16 +4,14 @@ import { useRouter } from "next/router"; export default function ClerkLogin() { const { query } = useRouter(); - const redirectUrl = query.redirectUrl - ? (query.return_to as string) - : undefined; + const returnTo = query.return_to as string; return ( ); } diff --git a/src/components/Authentication/Clerk/ClerkRegistration.tsx b/src/components/Authentication/Clerk/ClerkRegistration.tsx index bd876ab13..5986d2894 100644 --- a/src/components/Authentication/Clerk/ClerkRegistration.tsx +++ b/src/components/Authentication/Clerk/ClerkRegistration.tsx @@ -4,7 +4,7 @@ import { useRouter } from "next/router"; export default function ClerkRegistration() { const { query } = useRouter(); - const redirectUrl = query.redirectUrl ? query.return_to : undefined; + const returnTo = query.return_to as string; return (
@@ -15,7 +15,7 @@ export default function ClerkRegistration() { routing="path" signInUrl="/login" signInForceRedirectUrl={ - redirectUrl ? `/?return_to=${redirectUrl}` : undefined + returnTo ? `/?return_to=${returnTo}` : undefined } />