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.

increased FREE_PLAN_PROJECT_LIMIT from 1 to 5

Steven Teydd3ae17e6113
diff --git a/lib/auth.ts b/lib/auth.ts
index d536ee2a07..7220e1f4a3 100644
--- a/lib/auth.ts
+++ b/lib/auth.ts
@@ -3,6 +3,7 @@ import { unstable_getServerSession } from "next-auth/next";
import { authOptions } from "@/pages/api/auth/[...nextauth]";
import prisma from "@/lib/prisma";
import { ProjectProps, UsageProps, UserProps } from "@/lib/types";
+import { FREE_PLAN_PROJECT_LIMIT } from "@/lib/constants";
interface Session {
user: {
@@ -159,7 +160,11 @@ const withUserAuth =
})) as UserProps;
const freePlan = user.usageLimit === 1000;
- if (needProSubscription && freePlan && user.projects.length >= 5) {
+ if (
+ needProSubscription &&
+ freePlan &&
+ user.projects.length >= FREE_PLAN_PROJECT_LIMIT
+ ) {
return res
.status(403)
.end("Unauthorized: Can't add more projects, need pro subscription");
diff --git a/lib/constants.ts b/lib/constants.ts
index d49a6078b1..ebafe53383 100644
--- a/lib/constants.ts
+++ b/lib/constants.ts
@@ -51,6 +51,8 @@ export const DEFAULT_REDIRECTS = {
settings: "https://app.dub.sh/settings",
};
+export const FREE_PLAN_PROJECT_LIMIT = 5;
+
export const COUNTRIES: { [key: string]: string } = {
AF: "Afghanistan",
AL: "Albania",
diff --git a/pages/app/index.tsx b/pages/app/index.tsx
index 26816f6ed1..03720582e0 100644
--- a/pages/app/index.tsx
+++ b/pages/app/index.tsx
@@ -9,6 +9,7 @@ import NoProjectsPlaceholder from "@/components/app/no-projects-placeholder";
import ProjectCardPlaceholder from "@/components/app/project-card-placeholder";
import useUsage from "@/lib/swr/use-usage";
import Tooltip, { TooltipContent } from "@/components/shared/tooltip";
+import { FREE_PLAN_PROJECT_LIMIT } from "@/lib/constants";
export default function App() {
const { data } = useSWR<ProjectProps[]>(`/api/projects`, fetcher);
@@ -22,11 +23,11 @@ export default function App() {
<MaxWidthWrapper>
<div className="flex justify-between items-center">
<h1 className="text-2xl text-gray-600">My Projects</h1>
- {plan === "Free" && data?.length >= 1 ? (
+ {plan === "Free" && data?.length >= FREE_PLAN_PROJECT_LIMIT ? (
<Tooltip
content={
<TooltipContent
- title="You can only have 1 project on the Free plan. Upgrade to the Pro plan create more."
+ title={`You can only have ${FREE_PLAN_PROJECT_LIMIT} projects on the Free plan. Upgrade to the Pro plan create more.`}
cta="Upgrade"
ctaLink={`/settings`}
/>