Skip to content

Scheduling infrastructure for absolutely everyone.

feat: add disable signup feature flag (#9274)

Nafees Nazik75c914555809
diff --git a/apps/web/pages/signup.tsx b/apps/web/pages/signup.tsx
index 81181ecd2ed..8b73bf3cada 100644
--- a/apps/web/pages/signup.tsx
+++ b/apps/web/pages/signup.tsx
@@ -9,10 +9,10 @@ import { z } from "zod";
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
import { checkPremiumUsername } from "@calcom/features/ee/common/lib/checkPremiumUsername";
import { isSAMLLoginEnabled } from "@calcom/features/ee/sso/lib/saml";
+import { getFeatureFlagMap } from "@calcom/features/flags/server/utils";
import { IS_SELF_HOSTED, WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry";
-import prisma from "@calcom/prisma";
import type { inferSSRProps } from "@calcom/types/inferSSRProps";
import { Alert, Button, EmailField, HeadSeo, PasswordField, TextField } from "@calcom/ui";
@@ -158,6 +158,8 @@ export default function Signup({ prepopulateFormValues, token }: inferSSRProps<t
}
export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
+ const prisma = await import("@calcom/prisma").then((mod) => mod.default);
+ const flags = await getFeatureFlagMap(prisma);
const ssr = await ssrInit(ctx);
const token = z.string().optional().parse(ctx.query.token);
@@ -168,7 +170,9 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
prepopulateFormValues: undefined,
};
- if (process.env.NEXT_PUBLIC_DISABLE_SIGNUP === "true") {
+ if (process.env.NEXT_PUBLIC_DISABLE_SIGNUP === "true" || flags["disable-signup"]) {
+ console.log({ flag: flags["disable-signup"] });
+
return {
notFound: true,
};
diff --git a/packages/features/flags/config.ts b/packages/features/flags/config.ts
index 0883a9ff984..1baee4b82b6 100644
--- a/packages/features/flags/config.ts
+++ b/packages/features/flags/config.ts
@@ -11,4 +11,5 @@ export type AppFlags = {
"v2-booking-page": boolean;
"managed-event-types": boolean;
"google-workspace-directory": boolean;
+ "disable-signup": boolean;
};
diff --git a/packages/prisma/migrations/20230601181657_disable_signup_feature_flag/migration.sql b/packages/prisma/migrations/20230601181657_disable_signup_feature_flag/migration.sql
new file mode 100644
index 00000000000..fd12d660acf
--- /dev/null
+++ b/packages/prisma/migrations/20230601181657_disable_signup_feature_flag/migration.sql
@@ -0,0 +1,10 @@
+INSERT INTO
+ "Feature" (slug, enabled, description, "type")
+VALUES
+ (
+ 'disable-signup',
+ false,
+ 'Enable to prevent users from signing up',
+ 'OPERATIONAL'
+ ) ON CONFLICT (slug) DO NOTHING;
+
\ No newline at end of file