mirror of
https://github.com/supabase/supabase.git
synced 2026-05-07 01:10:15 -04:00
a4cfcd9b2e
* docs: user nav dropdown * www: user dropdown nav * update menus * chore: add complete local storage allowlist * move all local-storage to common * reload after logOut * add local storage key changes from #35175 * fix errors * add more keys * fix merge bugs --------- Co-authored-by: Alaister Young <a@alaisteryoung.com>
39 lines
897 B
TypeScript
39 lines
897 B
TypeScript
'use client'
|
|
|
|
import { useQueryClient } from '@tanstack/react-query'
|
|
import { AuthProvider, LOCAL_STORAGE_KEYS } from 'common'
|
|
import { type PropsWithChildren, useCallback } from 'react'
|
|
import { remove } from '~/lib/storage'
|
|
import { useOnLogout } from '~/lib/userAuth'
|
|
|
|
/**
|
|
*
|
|
* !!! IMPORTANT !!!
|
|
* Ensure data is cleared on sign out.
|
|
*
|
|
*/
|
|
const SignOutHandler = ({ children }: PropsWithChildren) => {
|
|
const queryClient = useQueryClient()
|
|
|
|
const cleanUp = useCallback(() => {
|
|
queryClient.cancelQueries()
|
|
queryClient.clear()
|
|
|
|
Object.keys(LOCAL_STORAGE_KEYS).forEach((key) => {
|
|
remove('local', LOCAL_STORAGE_KEYS[key])
|
|
})
|
|
}, [queryClient])
|
|
|
|
useOnLogout(cleanUp)
|
|
|
|
return <>{children}</>
|
|
}
|
|
|
|
const AuthContainer = ({ children }: PropsWithChildren) => (
|
|
<AuthProvider>
|
|
<SignOutHandler>{children}</SignOutHandler>
|
|
</AuthProvider>
|
|
)
|
|
|
|
export { AuthContainer }
|