Add environment variable to enable team creation for new users in self-hosted deployments (#74)
This commit is contained in:
@@ -17,4 +17,5 @@ NEXTAUTH_SECRET=""
|
|||||||
|
|
||||||
API_RATE_LIMIT=2
|
API_RATE_LIMIT=2
|
||||||
|
|
||||||
NEXT_PUBLIC_IS_CLOUD=false
|
NEXT_PUBLIC_IS_CLOUD=false
|
||||||
|
NEXT_PUBLIC_SELF_HOSTED_ALLOW_NEW_USERS=false
|
19
apps/web/src/components/team/TeamCreationDisabled.tsx
Normal file
19
apps/web/src/components/team/TeamCreationDisabled.tsx
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
export default function TeamCreationDisabled() {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center min-h-screen ">
|
||||||
|
<div className=" w-[300px] flex flex-col gap-8">
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-semibold text-center">Cannot sign up</h1>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="text-center">
|
||||||
|
Team creation is disabled. Please contact your administrator.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
@@ -66,6 +66,10 @@ export const env = createEnv({
|
|||||||
.string()
|
.string()
|
||||||
.default("false")
|
.default("false")
|
||||||
.transform((str) => str === "true"),
|
.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,
|
AWS_DEFAULT_REGION: process.env.AWS_DEFAULT_REGION,
|
||||||
API_RATE_LIMIT: process.env.API_RATE_LIMIT,
|
API_RATE_LIMIT: process.env.API_RATE_LIMIT,
|
||||||
NEXT_PUBLIC_IS_CLOUD: process.env.NEXT_PUBLIC_IS_CLOUD,
|
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,
|
ADMIN_EMAIL: process.env.ADMIN_EMAIL,
|
||||||
DISCORD_WEBHOOK_URL: process.env.DISCORD_WEBHOOK_URL,
|
DISCORD_WEBHOOK_URL: process.env.DISCORD_WEBHOOK_URL,
|
||||||
REDIS_URL: process.env.REDIS_URL,
|
REDIS_URL: process.env.REDIS_URL,
|
||||||
|
@@ -4,6 +4,7 @@ import { useSession } from "next-auth/react";
|
|||||||
import { FullScreenLoading } from "~/components/FullScreenLoading";
|
import { FullScreenLoading } from "~/components/FullScreenLoading";
|
||||||
import { AddSesSettings } from "~/components/settings/AddSesSettings";
|
import { AddSesSettings } from "~/components/settings/AddSesSettings";
|
||||||
import CreateTeam from "~/components/team/CreateTeam";
|
import CreateTeam from "~/components/team/CreateTeam";
|
||||||
|
import TeamCreationDisabled from "~/components/team/TeamCreationDisabled";
|
||||||
import { env } from "~/env";
|
import { env } from "~/env";
|
||||||
import { api } from "~/trpc/react";
|
import { api } from "~/trpc/react";
|
||||||
|
|
||||||
@@ -26,6 +27,14 @@ export const DashboardProvider = ({
|
|||||||
return <FullScreenLoading />;
|
return <FullScreenLoading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!env.NEXT_PUBLIC_IS_CLOUD &&
|
||||||
|
!env.NEXT_PUBLIC_SELF_HOSTED_ALLOW_NEW_USERS &&
|
||||||
|
(!teams || teams.length === 0)
|
||||||
|
) {
|
||||||
|
return <TeamCreationDisabled />;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
settings?.length === 0 &&
|
settings?.length === 0 &&
|
||||||
(!env.NEXT_PUBLIC_IS_CLOUD || session?.user.isAdmin)
|
(!env.NEXT_PUBLIC_IS_CLOUD || session?.user.isAdmin)
|
||||||
|
Reference in New Issue
Block a user