Skip to content

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

ref: Use non-deprecated delete user endpoint (#31095)

Kamil Ogórek643926d5b4eb
diff --git a/apps/studio/components/interfaces/Auth/Users/UserDropdown.tsx b/apps/studio/components/interfaces/Auth/Users/UserDropdown.tsx
index 35fb49e6832..b0c912a41a6 100644
--- a/apps/studio/components/interfaces/Auth/Users/UserDropdown.tsx
+++ b/apps/studio/components/interfaces/Auth/Users/UserDropdown.tsx
@@ -98,7 +98,8 @@ const UserDropdown = ({
async function handleDelete() {
await timeout(200)
if (!ref) return console.error('Project ref is required')
- deleteUser({ projectRef: ref, user })
+ if (!user.id) return console.error('User id is required')
+ deleteUser({ projectRef: ref, userId: user.id })
}
async function handleDeleteFactors() {
diff --git a/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx b/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx
index 886792b3204..958d95fe0c3 100644
--- a/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx
+++ b/apps/studio/components/interfaces/Auth/Users/UserOverview.tsx
@@ -132,7 +132,10 @@ export const UserOverview = ({ user, onDeleteSuccess }: UserOverviewProps) => {
const handleDelete = async () => {
await timeout(200)
if (!projectRef) return console.error('Project ref is required')
- deleteUser({ projectRef, user })
+ if (user.id === undefined) {
+ return toast.error(`Failed to delete user: User ID not found`)
+ }
+ deleteUser({ projectRef, userId: user.id })
}
const handleDeleteFactors = async () => {
@@ -142,7 +145,7 @@ export const UserOverview = ({ user, onDeleteSuccess }: UserOverviewProps) => {
}
const handleUnban = () => {
- if (projectRef === undefined) return console.error('Proejct ref is required')
+ if (projectRef === undefined) return console.error('Project ref is required')
if (user.id === undefined) {
return toast.error(`Failed to ban user: User ID not found`)
}
diff --git a/apps/studio/data/auth/user-delete-mutation.ts b/apps/studio/data/auth/user-delete-mutation.ts
index 9fe1975b892..5148f59147d 100644
--- a/apps/studio/data/auth/user-delete-mutation.ts
+++ b/apps/studio/data/auth/user-delete-mutation.ts
@@ -4,17 +4,15 @@ import { toast } from 'sonner'
import { del, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { authKeys } from './keys'
-import type { User } from './users-infinite-query'
export type UserDeleteVariables = {
projectRef: string
- user: User
+ userId: string
}
-export async function deleteUser({ projectRef, user }: UserDeleteVariables) {
- const { data, error } = await del('/platform/auth/{ref}/users', {
- params: { path: { ref: projectRef } },
- body: user,
+export async function deleteUser({ projectRef, userId }: UserDeleteVariables) {
+ const { data, error } = await del('/platform/auth/{ref}/users/{id}', {
+ params: { path: { ref: projectRef, id: userId } },
})
if (error) handleError(error)
return data