mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-08-23 23:02:04 +10:00
* Adding groups logic and restrictions * Cleaning up some redundant code * hastily made translations * Linter issues * More linting * PR comments * Covering other APIs with age filters per comment --------- Co-authored-by: Robert Clabough <robert@clabough.tech>
20 lines
669 B
TypeScript
20 lines
669 B
TypeScript
import aclManager from "~/server/internal/acls";
|
|
import prisma from "~/server/internal/db/database";
|
|
|
|
export default defineEventHandler(async (h3) => {
|
|
const allowed = await aclManager.allowSystemACL(h3, ["user:delete"]);
|
|
if (!allowed) throw createError({ statusCode: 403 });
|
|
|
|
const id = getRouterParam(h3, "id")!;
|
|
|
|
const group = await prisma.userGroup.findUnique({ where: { id } });
|
|
if (!group)
|
|
throw createError({ statusCode: 404, message: "Group not found" });
|
|
|
|
// SAFETY: existence verified above via findUnique
|
|
// eslint-disable-next-line drop/no-prisma-delete
|
|
await prisma.userGroup.delete({ where: { id } });
|
|
|
|
return { success: true };
|
|
});
|