The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fixed bug where user usageLimit doesn't propagate when creating new projects
Steven Teyfdaaac3e00d0
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsxindex a09601109f..e7365e458a 100644--- a/components/app/modals/add-edit-link-modal/index.tsx+++ b/components/app/modals/add-edit-link-modal/index.tsx@@ -339,25 +339,10 @@ function AddEditLinkButton({const router = useRouter();const { slug } = router.query as { slug?: string };- const { project, isOwner } = useProject();+ const { isOwner } = useProject();const { exceededUsage } = useUsage();- return project && !project.domainVerified ? (- <Tooltip- content={- <TooltipContent- title="This domain is not correctly configured. Please configure your domain to-start adding links."- cta="Configure Domain"- ctaLink={`/${slug}/settings`}- />- }- >- <div className="cursor-not-allowed rounded-md border border-gray-200 px-5 py-2 text-sm font-medium text-gray-300 transition-all duration-75">- Add- </div>- </Tooltip>- ) : slug && exceededUsage ? ( // only show exceeded usage tooltip if user is on a project page+ return slug && exceededUsage ? ( // only show exceeded usage tooltip if user is on a project page<Tooltipcontent={<TooltipContentdiff --git a/components/app/settings/landing-page.tsx b/components/app/settings/landing-page.tsxindex 315ad03a37..83e5c795ea 100644--- a/components/app/settings/landing-page.tsx+++ b/components/app/settings/landing-page.tsx@@ -80,7 +80,7 @@ export default function LandingPage() {)}</div><div />- {domainVerified && plan !== "Free" ? (+ {plan !== "Free" ? (<inputtype="url"name="root"@@ -93,19 +93,15 @@ export default function LandingPage() {) : (<Tooltipcontent={- !domainVerified ? (- "You need to verify your domain first."- ) : (- <TooltipContent- title={`You can't configure a custom landing page on a free plan. ${- isOwner- ? "Upgrade to a Pro plan to proceed."- : "Ask your project owner to upgrade to a Pro plan."- }`}- cta={isOwner && "Upgrade to Pro"}- ctaLink={isOwner && "/settings"}- />- )+ <TooltipContent+ title={`You can't configure a custom landing page on a free plan. ${+ isOwner+ ? "Upgrade to a Pro plan to proceed."+ : "Ask your project owner to upgrade to a Pro plan."+ }`}+ cta={isOwner && "Upgrade to Pro"}+ ctaLink={isOwner && "/settings"}+ />}><div className="w-full max-w-md cursor-not-allowed rounded-md border border-gray-300 px-3 py-2 text-left text-sm text-gray-300">@@ -118,7 +114,7 @@ export default function LandingPage() {<div className="border-b border-gray-200" /><div className="px-5 py-4 sm:flex sm:items-center sm:justify-end sm:px-10">- {domainVerified && plan !== "Free" ? (+ {plan !== "Free" ? (<buttondisabled={saving}className={`${@@ -132,19 +128,15 @@ export default function LandingPage() {) : (<Tooltipcontent={- !domainVerified ? (- "You need to verify your domain first."- ) : (- <TooltipContent- title={`You can't configure a custom landing page on a free plan. ${- isOwner- ? "Upgrade to a Pro plan to proceed."- : "Ask your project owner to upgrade to a Pro plan."- }`}- cta={isOwner && "Upgrade to Pro"}- ctaLink={isOwner && "/settings"}- />- )+ <TooltipContent+ title={`You can't configure a custom landing page on a free plan. ${+ isOwner+ ? "Upgrade to a Pro plan to proceed."+ : "Ask your project owner to upgrade to a Pro plan."+ }`}+ cta={isOwner && "Upgrade to Pro"}+ ctaLink={isOwner && "/settings"}+ />}fullWidth>diff --git a/lib/auth.ts b/lib/auth.tsindex 3643302525..c31337d6b8 100644--- a/lib/auth.ts+++ b/lib/auth.ts@@ -32,12 +32,10 @@ const withProjectAuth =handler: WithProjectNextApiHandler,{excludeGet, // if the action doesn't need to be gated for GET requests- needVerifiedDomain, // if the action needs a verified domainneedProSubscription, // if the action needs a pro subscriptionneedNotExceededUsage, // if the action needs the user to not have exceeded their usage}: {excludeGet?: boolean;- needVerifiedDomain?: boolean;needProSubscription?: boolean;needNotExceededUsage?: boolean;} = {},@@ -107,11 +105,6 @@ const withProjectAuth =// if the action doesn't need to be gated for GET requests, return handler nowif (req.method === "GET" && excludeGet) return handler(req, res, project);- // if the action needs a verified domain, check if the project has one, if not return 403- if (needVerifiedDomain && !project.domainVerified) {- return res.status(403).json({ error: "Domain not verified." });- }-if (needNotExceededUsage || needProSubscription) {if (needNotExceededUsage && project.ownerExceededUsage) {return res.status(403).end("Unauthorized: Usage limits exceeded.");diff --git a/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.ts b/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.tsindex c5ab502e40..96d27016d1 100644--- a/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.ts+++ b/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.ts@@ -22,7 +22,4 @@ export default withProjectAuth(.json({ error: `Method ${req.method} Not Allowed` });}},- {- needVerifiedDomain: true,- },);diff --git a/pages/api/projects/[slug]/domains/[domain]/links/[key]/index.ts b/pages/api/projects/[slug]/domains/[domain]/links/[key]/index.tsindex 4b4e9719b9..4bcd487a9e 100644--- a/pages/api/projects/[slug]/domains/[domain]/links/[key]/index.ts+++ b/pages/api/projects/[slug]/domains/[domain]/links/[key]/index.ts@@ -46,7 +46,6 @@ export default withProjectAuth(}},{- needVerifiedDomain: true,needNotExceededUsage: true,},);diff --git a/pages/api/projects/[slug]/domains/[domain]/links/index.ts b/pages/api/projects/[slug]/domains/[domain]/links/index.tsindex 0d2f247805..374c125fc5 100644--- a/pages/api/projects/[slug]/domains/[domain]/links/index.ts+++ b/pages/api/projects/[slug]/domains/[domain]/links/index.ts@@ -48,7 +48,6 @@ export default withProjectAuth(},{excludeGet: true,- needVerifiedDomain: true,needNotExceededUsage: true,},);diff --git a/pages/api/projects/[slug]/domains/[domain]/root/index.ts b/pages/api/projects/[slug]/domains/[domain]/root/index.tsindex 743e898dc7..3cb065ab5a 100644--- a/pages/api/projects/[slug]/domains/[domain]/root/index.ts+++ b/pages/api/projects/[slug]/domains/[domain]/root/index.ts@@ -25,9 +25,7 @@ export default withProjectAuth(},{excludeGet: true,- needVerifiedDomain: true,needNotExceededUsage: true,- // TODO: For when we make this a pro feature- // needProSubscription: true,+ needProSubscription: true,},);diff --git a/pages/api/projects/index.ts b/pages/api/projects/index.tsindex 4e0b0090f7..ebe8a17e75 100644--- a/pages/api/projects/index.ts+++ b/pages/api/projects/index.ts@@ -67,12 +67,22 @@ export default withUserAuth(});}+ const { usageLimit: ownerUsageLimit } = await prisma.user.findUnique({+ where: {+ id: session.user.id,+ },+ select: {+ usageLimit: true,+ },+ });+const [prismaResponse, domainResponse] = await Promise.all([prisma.project.create({data: {name,slug,domain,+ ownerUsageLimit,users: {create: {userId: session.user.id,