The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Refactor user deletion logic in workspace route
Kiran K4e138d623d94
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/users/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/users/route.tsindex fecd016ee0..d17733bb55 100644--- a/apps/web/app/api/workspaces/[idOrSlug]/users/route.ts+++ b/apps/web/app/api/workspaces/[idOrSlug]/users/route.ts@@ -135,14 +135,25 @@ export const DELETE = withWorkspace(});}- const response = await prisma.projectUsers.delete({- where: {- userId_projectId: {+ const [response] = await Promise.allSettled([+ // Remove the user from the workspace+ prisma.projectUsers.delete({+ where: {+ userId_projectId: {+ projectId: workspace.id,+ userId,+ },+ },+ }),++ // Remove tokens associated with the user from the workspace+ prisma.restrictedToken.deleteMany({+ where: {projectId: workspace.id,userId,},- },- });+ }),+ ]);if (projectUser.user.isMachine) {await prisma.user.delete({