Skip to content

Commit

Permalink
fix: fix incorrect loading of admin ui settings page (#2805)
Browse files Browse the repository at this point in the history
* fix: fix incorrect loading of Admin UI settings page using redirectDocument

* fix: handle direct navigation to the login and account recovery endpoints
  • Loading branch information
JoblersTune authored Jul 15, 2024
1 parent 92fff83 commit 9af1dcb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
13 changes: 8 additions & 5 deletions packages/frontend/app/routes/auth.login.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
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'
Expand Down Expand Up @@ -34,10 +38,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`
)
}
}

Expand Down
13 changes: 8 additions & 5 deletions packages/frontend/app/routes/auth.recovery.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
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'
Expand Down Expand Up @@ -35,10 +39,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`
)
}
}

Expand Down
8 changes: 6 additions & 2 deletions packages/frontend/app/routes/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { json, redirect, type LoaderFunctionArgs } from '@remix-run/node'
import {
json,
redirectDocument,
type LoaderFunctionArgs
} from '@remix-run/node'
import { uuidSchema } from '~/lib/validate.server'
import {
isUiNodeInputAttributes,
Expand Down Expand Up @@ -39,7 +43,7 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {

return { responseData }
} else {
return redirect(
return redirectDocument(
`${variables.kratosBrowserPublicUrl}/self-service/settings/browser`
)
}
Expand Down

0 comments on commit 9af1dcb

Please sign in to comment.