disable multiple team creation for self-hosters

This commit is contained in:
KMKoushik
2024-10-20 08:25:48 +11:00
parent 2391d1c306
commit 2db31cda35
7 changed files with 18 additions and 36 deletions

View File

@@ -1,4 +1,6 @@
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { env } from "~/env";
import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc";
@@ -21,6 +23,16 @@ export const teamRouter = createTRPCRouter({
return;
}
if (!env.NEXT_PUBLIC_IS_CLOUD) {
const _team = await ctx.db.team.findFirst();
if (_team) {
throw new TRPCError({
message: "Can't have multiple teams in self hosted version",
code: "UNAUTHORIZED",
});
}
}
return ctx.db.team.create({
data: {
name: input.name,