The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix remove self from project
Steven Tey1f00a962efa4
diff --git a/apps/web/app/api/projects/[slug]/users/route.ts b/apps/web/app/api/projects/[slug]/users/route.tsindex 341a12e8aa..6f1f84ac97 100644--- a/apps/web/app/api/projects/[slug]/users/route.ts+++ b/apps/web/app/api/projects/[slug]/users/route.ts@@ -91,5 +91,6 @@ export const DELETE = withAuth(},{requiredRole: ["owner"],+ allowSelf: true,},);diff --git a/apps/web/lib/auth/index.ts b/apps/web/lib/auth/index.tsindex ddd22178d5..cc97bd5d1f 100644--- a/apps/web/lib/auth/index.ts+++ b/apps/web/lib/auth/index.ts@@ -67,11 +67,13 @@ export const withAuth =requiredRole = ["owner", "member"],needNotExceededUsage, // if the action needs the user to not have exceeded their usageallowAnonymous, // special case for /api/links (POST /api/links) – allow no session+ allowSelf, // special case for removing yourself from a project}: {requiredPlan?: Array<PlanProps>;requiredRole?: Array<"owner" | "member">;needNotExceededUsage?: boolean;allowAnonymous?: boolean;+ allowSelf?: boolean;} = {},) =>async (@@ -300,11 +302,7 @@ export const withAuth =requiredRole &&project.plan === "enterprise" &&!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"- )+ !(allowSelf && searchParams.userId === session.user.id)) {return new Response("Unauthorized: Insufficient permissions.", {status: 403,