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
+1 -1
View File
@@ -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" });
}
+18 -4
View File
@@ -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(),