/
home
/
techb158
/
balavpn.abdallabala.com
/
src
/
app
/
api
/
admin
/
super-admins
/
[id]
/
/home/techb158/balavpn.abdallabala.com/src/app/api/admin/super-admins/[id]
mkdir
upload
Name
Size
Mode
Actions
route.js
919
0644
edit
dl
rm
Edit:
/home/techb158/balavpn.abdallabala.com/src/app/api/admin/super-admins/[id]/route.js
(919B)
const { prisma } = require("../../../../../lib/prisma"); const { jsonResponse, errorResponse } = require("../../../../../lib/http"); const { requireSuperOwner } = require("../../../../../lib/request-context"); export async function DELETE(request, { params }) { try { await requireSuperOwner(request); const { id } = await params; const user = await prisma.user.findUnique({ where: { id } }); if (!user) return jsonResponse({ error: "User not found" }, 404); if (user.platformRole === "SUPER_OWNER") return jsonResponse({ error: "Cannot remove Super Owner" }, 403); if (user.platformRole !== "SUPER_ADMIN") return jsonResponse({ error: "User is not a Super Admin" }, 400); await prisma.user.update({ where: { id }, data: { platformRole: "NONE" } }); return jsonResponse({ message: "Super Admin removed" }); } catch (error) { return errorResponse(error); } }
Save
cmd:
run