From f3175af9f6e30ead4caf3ba0199edba887dfd20a Mon Sep 17 00:00:00 2001 From: JoblersTune Date: Mon, 15 Jul 2024 09:38:30 +0200 Subject: [PATCH] chore: handle direct navigation to the login and account recovery endpoints --- packages/frontend/app/routes/auth.login.tsx | 9 ++++----- packages/frontend/app/routes/auth.recovery.tsx | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/frontend/app/routes/auth.login.tsx b/packages/frontend/app/routes/auth.login.tsx index cc01536a81..5de81ffa2c 100644 --- a/packages/frontend/app/routes/auth.login.tsx +++ b/packages/frontend/app/routes/auth.login.tsx @@ -1,4 +1,4 @@ -import { json, type LoaderFunctionArgs } from '@remix-run/node' +import { json, type LoaderFunctionArgs, redirectDocument, } from '@remix-run/node' import { uuidSchema } from '~/lib/validate.server' import { isUiNodeInputAttributes } from '@ory/integrations/ui' import type { UiContainer } from '@ory/client' @@ -34,10 +34,9 @@ export const loader = async ({ request }: LoaderFunctionArgs) => { const recoveryUrl = `${variables.kratosBrowserPublicUrl}/self-service/recovery/browser` return { responseData, recoveryUrl } } else { - throw json(null, { - status: 400, - statusText: 'No Kratos login flow ID found.' - }) + return redirectDocument( + `${variables.kratosBrowserPublicUrl}/self-service/login/browser` + ) } } diff --git a/packages/frontend/app/routes/auth.recovery.tsx b/packages/frontend/app/routes/auth.recovery.tsx index d6b165abc8..e53f6b9882 100644 --- a/packages/frontend/app/routes/auth.recovery.tsx +++ b/packages/frontend/app/routes/auth.recovery.tsx @@ -1,4 +1,4 @@ -import { json, type LoaderFunctionArgs } from '@remix-run/node' +import { json, type LoaderFunctionArgs, redirectDocument } from '@remix-run/node' import { uuidSchema } from '~/lib/validate.server' import { isUiNodeInputAttributes } from '@ory/integrations/ui' import type { UiContainer } from '@ory/client' @@ -35,10 +35,9 @@ export const loader = async ({ request }: LoaderFunctionArgs) => { return { responseData } } else { - throw json(null, { - status: 400, - statusText: 'No Kratos account recovery flow ID found.' - }) + return redirectDocument( + `${variables.kratosBrowserPublicUrl}/self-service/recovery/browser` + ) } }