enable waitlisting in cloud

This commit is contained in:
KM Koushik
2025-09-17 22:13:03 +10:00
parent 8c8af1f846
commit e1cb1f27d1
6 changed files with 41 additions and 6 deletions

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "User" ADD COLUMN "isWaitlisted" BOOLEAN NOT NULL DEFAULT false;

View File

@@ -85,6 +85,7 @@ model User {
emailVerified DateTime? emailVerified DateTime?
image String? image String?
isBetaUser Boolean @default(false) isBetaUser Boolean @default(false)
isWaitlisted Boolean @default(false)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
accounts Account[] accounts Account[]
sessions Session[] sessions Session[]

View File

@@ -8,5 +8,9 @@ export default async function Home() {
redirect("/login"); redirect("/login");
} }
redirect("/dashboard"); if (session.user.isWaitlisted) {
redirect("/wait-list");
} else {
redirect("/dashboard");
}
} }

View File

@@ -35,5 +35,19 @@ const AppAuthProvider = ({ children }: { children: React.ReactNode }) => {
return <LoginPage />; return <LoginPage />;
} }
if (session.user.isWaitlisted) {
return (
<div className="flex items-center justify-center min-h-screen ">
<div className="p-8 shadow-lg rounded-lg flex flex-col gap-4">
<Rocket />
<h1 className="text-2xl font-bold">You're on the Waitlist!</h1>
<p className=" text-secondary-muted">
Hang tight, we'll get to you as soon as possible.
</p>
</div>
</div>
);
}
return <>{children}</>; return <>{children}</>;
}; };

View File

@@ -99,7 +99,7 @@ export const publicProcedure = t.procedure;
* @see https://trpc.io/docs/procedures * @see https://trpc.io/docs/procedures
*/ */
export const protectedProcedure = t.procedure.use(({ ctx, next }) => { export const protectedProcedure = t.procedure.use(({ ctx, next }) => {
if (!ctx.session || !ctx.session.user) { if (!ctx.session || !ctx.session.user || ctx.session.user.isWaitlisted) {
throw new TRPCError({ code: "UNAUTHORIZED" }); throw new TRPCError({ code: "UNAUTHORIZED" });
} }

View File

@@ -27,6 +27,7 @@ declare module "next-auth" {
id: number; id: number;
isBetaUser: boolean; isBetaUser: boolean;
isAdmin: boolean; isAdmin: boolean;
isWaitlisted: boolean;
// ...other properties // ...other properties
// role: UserRole; // role: UserRole;
} & DefaultSession["user"]; } & DefaultSession["user"];
@@ -37,6 +38,7 @@ declare module "next-auth" {
id: number; id: number;
isBetaUser: boolean; isBetaUser: boolean;
isAdmin: boolean; isAdmin: boolean;
isWaitlisted: boolean;
} }
} }
@@ -107,6 +109,7 @@ export const authOptions: NextAuthOptions = {
id: user.id, id: user.id,
isBetaUser: user.isBetaUser, isBetaUser: user.isBetaUser,
isAdmin: user.email === env.ADMIN_EMAIL, isAdmin: user.email === env.ADMIN_EMAIL,
isWaitlisted: user.isWaitlisted,
}, },
}), }),
}, },
@@ -126,10 +129,21 @@ export const authOptions: NextAuthOptions = {
invitesAvailable = invites.length > 0; invitesAvailable = invites.length > 0;
} }
await db.user.update({ if (
where: { id: user.id }, !env.NEXT_PUBLIC_IS_CLOUD ||
data: { isBetaUser: true }, env.NODE_ENV === "development" ||
}); invitesAvailable
) {
await db.user.update({
where: { id: user.id },
data: { isBetaUser: true },
});
} else {
await db.user.update({
where: { id: user.id },
data: { isBetaUser: true, isWaitlisted: true },
});
}
}, },
}, },
providers: getProviders(), providers: getProviders(),