Files
supabase/apps/studio/routes/project/$ref/logs/auth-logs.tsx
supabase-vercel-tedd[bot] cf556ebd2a fix(studio): wait for permissions before showing no-permission on auth logs (#53527)
## Problem

The auth logs route rendered the full-page `NoPermission` state whenever
`useAsyncCheckPermissionsV2` returned `can: false`. The hook returns
`can: false` until the permissions query succeeds. Users who can read
logs therefore saw a short "No permission" flash before the logs loaded.

## Solution

`apps/studio/routes/project/$ref/logs/auth-logs.tsx` now reads
`isSuccess` from `useAsyncCheckPermissionsV2`:

- While permissions load, the route renders nothing.
- Once they load, a user without `ANALYTICS_LOGS_READ` gets the
full-page `NoPermission` state.
- Otherwise the route renders `LogsPreviewer` as before.

This is the same `isSuccess && !can` gating that other routes use, such
as `database/extensions.tsx`. No other route under
`routes/project/$ref/logs/` uses this pattern.

## How to verify

- As a user with log access, open `/project/<ref>/logs/auth-logs`.
Hard-reload the page. The "No permission" state never appears, and the
auth logs view loads.
- As a user without analytics log read access, open
`/project/<ref>/logs/auth-logs`. The page shows the full-page "No
permission" state for authentication logs.

## Checks run

- `pnpm turbo run typecheck --filter='...[origin/master]'`: pass
- `pnpm turbo run lint --filter='[origin/master]'`: pass, no errors. It
ran out of memory once at the default heap and passed with
`NODE_OPTIONS=--max-old-space-size=8192`.
- Prettier check on the changed file: pass
- No unit tests cover this route.


[FE-5121](https://linear.app/supabase/issue/FE-5121/auth-logs-page-flashes-no-permission-while-permissions-load)

Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
2026-11-17 09:18:05 -06:00

29 lines
1.0 KiB
TypeScript

import { createFileRoute } from '@tanstack/react-router'
import { LogsPreviewer } from '@/components/interfaces/Settings/Logs/LogsPreviewer'
import { NoPermission } from '@/components/ui/NoPermission'
import { FGA_PERMISSIONS, useAsyncCheckPermissionsV2 } from '@/hooks/misc/useCheckPermissionsV2'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
export const Route = createFileRoute('/project/$ref/logs/auth-logs')({
component: LogsPage,
staticData: { logsLayoutTitle: 'Auth Logs' },
})
function LogsPage() {
const { data: project } = useSelectedProjectQuery()
const { can: canReadAuthLogs, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissionsV2(
FGA_PERMISSIONS.PROJECT.ANALYTICS_LOGS_READ
)
if (!isPermissionsLoaded) return null
if (!canReadAuthLogs) {
return <NoPermission isFullPage resourceText="access your project's authentication logs" />
}
return !!project ? (
<LogsPreviewer condensedLayout projectRef={project.ref} queryType="auth" />
) : null
}