mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-15 09:11:21 +10:00
feat: add ability to review and revoke clients
This commit is contained in:
17
server/api/v1/user/client/[id]/index.delete.ts
Normal file
17
server/api/v1/user/client/[id]/index.delete.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import clientHandler from "~/server/internal/clients/handler";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const userId = await aclManager.getUserIdACL(h3, ["clients:revoke"]);
|
||||
if (!userId) throw createError({ statusCode: 403 });
|
||||
|
||||
const clientId = getRouterParam(h3, "id");
|
||||
if (!clientId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Client ID missing in route params",
|
||||
});
|
||||
|
||||
await clientHandler.removeClient(clientId);
|
||||
});
|
||||
15
server/api/v1/user/client/index.get.ts
Normal file
15
server/api/v1/user/client/index.get.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const userId = await aclManager.getUserIdACL(h3, ["clients:read"]);
|
||||
if (!userId) throw createError({ statusCode: 403 });
|
||||
|
||||
const clients = await prisma.client.findMany({
|
||||
where: {
|
||||
userId,
|
||||
},
|
||||
});
|
||||
|
||||
return clients;
|
||||
});
|
||||
Reference in New Issue
Block a user