Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

allow remove self

Steven Teyb28ac65f0bb7
diff --git a/lib/auth.ts b/lib/auth.ts
index 4db3d67905..680c0821dc 100644
--- a/lib/auth.ts
+++ b/lib/auth.ts
@@ -116,9 +116,15 @@ const withProjectAuth =
return handler(req, res, project, session);
}
+ console.log(req.url);
if (
project.plan === "enterprise" &&
- !requiredRole.includes(project.users[0].role)
+ !requiredRole.includes(project.users[0].role) &&
+ // removing self from project should be allowed (DELETE /api/projects/[slug]/users?userId=...)
+ !(
+ req.url === `/api/projects/${slug}/users?userId=${session.user.id}` &&
+ req.method === "DELETE"
+ )
) {
return res.status(403).end("Unauthorized: Insufficient permissions.");
}