Skip to content

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

Add missing users delete endpoint for local/self-host (#32945)

Joshen Limc635d46b534a
diff --git a/apps/studio/pages/api/platform/auth/[ref]/users/[id]/index.ts b/apps/studio/pages/api/platform/auth/[ref]/users/[id]/index.ts
index 531cf3ba6f7..ce688897c2f 100644
--- a/apps/studio/pages/api/platform/auth/[ref]/users/[id]/index.ts
+++ b/apps/studio/pages/api/platform/auth/[ref]/users/[id]/index.ts
@@ -13,6 +13,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
switch (method) {
case 'PATCH':
return handlePatch(req, res)
+ case 'DELETE':
+ return handleDelete(req, res)
default:
res.setHeader('Allow', ['PATCH'])
res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
@@ -27,3 +29,11 @@ const handlePatch = async (req: NextApiRequest, res: NextApiResponse) => {
if (error) return res.status(400).json({ error: { message: error.message } })
return res.status(200).json(data.user)
}
+
+const handleDelete = async (req: NextApiRequest, res: NextApiResponse) => {
+ const { id } = req.query
+ const { error } = await supabase.auth.admin.deleteUser(id as string)
+
+ if (error) return res.status(400).json({ error: { message: error.message } })
+ return res.status(200).send(undefined)
+}