Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Load orgs after profile endpoint in auth provider

Joshen Lim75b6f07136c5
diff --git a/studio/lib/auth.tsx b/studio/lib/auth.tsx
index 902be2efd73..29e1f6181d0 100644
--- a/studio/lib/auth.tsx
+++ b/studio/lib/auth.tsx
@@ -58,7 +58,7 @@ export const AuthContext = createContext<AuthContext>({
export type AuthProviderProps = {}
export const AuthProvider = ({ children }: PropsWithChildren<AuthProviderProps>) => {
- const { ui } = useStore()
+ const { ui, app } = useStore()
const [session, setSession] = useState<Session | null>(null)
const [isLoading, setIsLoading] = useState(true)
@@ -121,6 +121,12 @@ export const AuthProvider = ({ children }: PropsWithChildren<AuthProviderProps>)
useProfileQuery({
onSuccess(profile) {
ui.setProfile(profile)
+
+ // [Joshen] Temp fix: For new users, the GET profile call also creates a default org
+ // But because the dashboard's logged in state is using gotrue as the source of truth
+ // the home page loads before the GET profile call completes (and consequently before the
+ // creation of the default org). Hence why calling org load here
+ app.organizations.load()
},
// Never rerun the query
staleTime: Infinity,