mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 14:19:11 +03:00
## Problem React Query cache keys for permissions and organizations are generic (`['permissions']`, `['organizations']`) with no user identifier. When a new session is established without going through the explicit sign-out flow (e.g. clicking an email verification link while still logged in as another account), stale data from the previous user persists in cache. The new user ends up seeing the old user's permissions and org list, which makes the project creation form appear enabled. When submitted, the backend rejects with "not an owner" because the token belongs to the new account which has no ownership of the old org. A hard refresh clears the in-memory React Query state and forces a fresh fetch, which is why it resolved the issue. ## Fix Scope `permissionKeys.list` and `organizationKeys.list` by user ID so different accounts never share the same cache slot. When a different user logs in, their queries simply get fresh cache entries and never see data from the previous session. Updated all invalidation and `setQueriesData` call sites across 18 files to pass the current user ID. ## How to test I don't think it can be tested in the preview environment sadly since the request to verify has to go to auth.supabase.green instead of vercel-ref.supabase.green --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Writing components
Where to create your components
- For components that declare the general structure and layout of a page:
/components/layouts/xxx
- For components that are tightly coupled to a specific interface:
/components/interfaces/xxx
- For components that are meant to be reusable across multiple pages:
/components/ui/xxx
- Note: We're gradually moving files out of the
to-be-cleanedfolder into the respective folders as we refactor
Component structure
- If a component has constants and utility methods that are tightly coupled to itself, keep them close to the component and enclose them in a folder with an
index.tsxas an entry point - Otherwise it can just be a file on its own
- For example:
-
components/ui - SampleComponentA - SampleComponentA.tsx - SampleComponentA.constants.ts - SampleComponentA.utils.ts - SampleComponentA.types.ts - index.ts - SampleComponentB.tsx
-
Template for building components
// Declare the prop types of your component
interface ComponentAProps {
sampleProp: string
}
// Name your component accordingly
const ComponentA = ({ sampleProp }: ComponentAProps) => {
return <div>ComponentA: {sampleProp}</div>
}
export default ComponentA