mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(user): add organization count check before user deletion
This commit is contained in:
@@ -313,4 +313,18 @@ export const userRouter = createTRPCRouter({
|
||||
const apiKey = await createApiKey(ctx.user.id, input);
|
||||
return apiKey;
|
||||
}),
|
||||
|
||||
checkUserOrganizations: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
userId: z.string(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ input }) => {
|
||||
const organizations = await db.query.member.findMany({
|
||||
where: eq(member.userId, input.userId),
|
||||
});
|
||||
|
||||
return organizations.length;
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user