enable waitlisting in cloud
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" ADD COLUMN "isWaitlisted" BOOLEAN NOT NULL DEFAULT false;
|
@@ -85,6 +85,7 @@ model User {
|
||||
emailVerified DateTime?
|
||||
image String?
|
||||
isBetaUser Boolean @default(false)
|
||||
isWaitlisted Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
|
@@ -8,5 +8,9 @@ export default async function Home() {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
redirect("/dashboard");
|
||||
if (session.user.isWaitlisted) {
|
||||
redirect("/wait-list");
|
||||
} else {
|
||||
redirect("/dashboard");
|
||||
}
|
||||
}
|
||||
|
@@ -35,5 +35,19 @@ const AppAuthProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
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}</>;
|
||||
};
|
||||
|
@@ -99,7 +99,7 @@ export const publicProcedure = t.procedure;
|
||||
* @see https://trpc.io/docs/procedures
|
||||
*/
|
||||
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" });
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,7 @@ declare module "next-auth" {
|
||||
id: number;
|
||||
isBetaUser: boolean;
|
||||
isAdmin: boolean;
|
||||
isWaitlisted: boolean;
|
||||
// ...other properties
|
||||
// role: UserRole;
|
||||
} & DefaultSession["user"];
|
||||
@@ -37,6 +38,7 @@ declare module "next-auth" {
|
||||
id: number;
|
||||
isBetaUser: boolean;
|
||||
isAdmin: boolean;
|
||||
isWaitlisted: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +109,7 @@ export const authOptions: NextAuthOptions = {
|
||||
id: user.id,
|
||||
isBetaUser: user.isBetaUser,
|
||||
isAdmin: user.email === env.ADMIN_EMAIL,
|
||||
isWaitlisted: user.isWaitlisted,
|
||||
},
|
||||
}),
|
||||
},
|
||||
@@ -126,10 +129,21 @@ export const authOptions: NextAuthOptions = {
|
||||
invitesAvailable = invites.length > 0;
|
||||
}
|
||||
|
||||
await db.user.update({
|
||||
where: { id: user.id },
|
||||
data: { isBetaUser: true },
|
||||
});
|
||||
if (
|
||||
!env.NEXT_PUBLIC_IS_CLOUD ||
|
||||
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(),
|
||||
|
Reference in New Issue
Block a user