diff --git a/.env.example b/.env.example
index 49825a9..351a5f7 100644
--- a/.env.example
+++ b/.env.example
@@ -17,4 +17,5 @@ NEXTAUTH_SECRET=""
API_RATE_LIMIT=2
-NEXT_PUBLIC_IS_CLOUD=false
\ No newline at end of file
+NEXT_PUBLIC_IS_CLOUD=false
+NEXT_PUBLIC_SELF_HOSTED_ALLOW_NEW_USERS=false
\ No newline at end of file
diff --git a/apps/web/src/components/team/TeamCreationDisabled.tsx b/apps/web/src/components/team/TeamCreationDisabled.tsx
new file mode 100644
index 0000000..a61d821
--- /dev/null
+++ b/apps/web/src/components/team/TeamCreationDisabled.tsx
@@ -0,0 +1,19 @@
+"use client";
+
+export default function TeamCreationDisabled() {
+
+ return (
+
+
+
+
Cannot sign up
+
+
+
+ Team creation is disabled. Please contact your administrator.
+
+
+
+
+ );
+}
diff --git a/apps/web/src/env.js b/apps/web/src/env.js
index 116538a..59fd4b8 100644
--- a/apps/web/src/env.js
+++ b/apps/web/src/env.js
@@ -66,6 +66,10 @@ export const env = createEnv({
.string()
.default("false")
.transform((str) => str === "true"),
+ NEXT_PUBLIC_SELF_HOSTED_ALLOW_NEW_USERS: z
+ .string()
+ .default("false")
+ .transform((str) => str === "true"),
},
/**
@@ -87,6 +91,8 @@ export const env = createEnv({
AWS_DEFAULT_REGION: process.env.AWS_DEFAULT_REGION,
API_RATE_LIMIT: process.env.API_RATE_LIMIT,
NEXT_PUBLIC_IS_CLOUD: process.env.NEXT_PUBLIC_IS_CLOUD,
+ NEXT_PUBLIC_SELF_HOSTED_ALLOW_NEW_USERS:
+ process.env.NEXT_PUBLIC_SELF_HOSTED_ALLOW_NEW_USERS,
ADMIN_EMAIL: process.env.ADMIN_EMAIL,
DISCORD_WEBHOOK_URL: process.env.DISCORD_WEBHOOK_URL,
REDIS_URL: process.env.REDIS_URL,
diff --git a/apps/web/src/providers/dashboard-provider.tsx b/apps/web/src/providers/dashboard-provider.tsx
index 00f93cd..933fb70 100644
--- a/apps/web/src/providers/dashboard-provider.tsx
+++ b/apps/web/src/providers/dashboard-provider.tsx
@@ -4,6 +4,7 @@ import { useSession } from "next-auth/react";
import { FullScreenLoading } from "~/components/FullScreenLoading";
import { AddSesSettings } from "~/components/settings/AddSesSettings";
import CreateTeam from "~/components/team/CreateTeam";
+import TeamCreationDisabled from "~/components/team/TeamCreationDisabled";
import { env } from "~/env";
import { api } from "~/trpc/react";
@@ -26,6 +27,14 @@ export const DashboardProvider = ({
return ;
}
+ if (
+ !env.NEXT_PUBLIC_IS_CLOUD &&
+ !env.NEXT_PUBLIC_SELF_HOSTED_ALLOW_NEW_USERS &&
+ (!teams || teams.length === 0)
+ ) {
+ return ;
+ }
+
if (
settings?.length === 0 &&
(!env.NEXT_PUBLIC_IS_CLOUD || session?.user.isAdmin)