diff --git a/.env.docker b/.env.docker index f4257259a0..c47b63398d 100644 --- a/.env.docker +++ b/.env.docker @@ -44,6 +44,9 @@ NEXT_PUBLIC_EMAIL_VERIFICATION_DISABLED=1 # Password Reset. If you enable Password Reset functionality you have to setup SMTP-Settings, too. NEXT_PUBLIC_PASSWORD_RESET_DISABLED=1 +# Signup. Disable the ability for new users to create an account. +# NEXT_PUBLIC_SIGNUP_DISABLED=1 + ####################### # Additional Options # ####################### diff --git a/.env.example b/.env.example index fc5db4508c..5859acd4a7 100644 --- a/.env.example +++ b/.env.example @@ -46,6 +46,9 @@ SMTP_PASSWORD=smtpPassword # Password Reset. If you enable Password Reset functionality you have to setup SMTP-Settings, too. # NEXT_PUBLIC_PASSWORD_RESET_DISABLED=1 +# Signup. Disable the ability for new users to create an account. +# NEXT_PUBLIC_SIGNUP_DISABLED=1 + ####################### # Additional Options # ####################### diff --git a/apps/web/pages/api/public/users/index.tsx b/apps/web/pages/api/public/users/index.tsx index 9b555474b2..2374244d7d 100644 --- a/apps/web/pages/api/public/users/index.tsx +++ b/apps/web/pages/api/public/users/index.tsx @@ -9,6 +9,10 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse) // Required fields in body: email, password (hashed) // Optional fields in body: firstname, lastname if (req.method === "POST") { + if (process.env.NEXT_PUBLIC_SIGNUP_DISABLED) { + res.status(403).json({ error: "Signup disabled" }); + return; + } let user = req.body; user = { ...user, ...{ email: user.email.toLowerCase() } }; diff --git a/apps/web/pages/auth/signin.tsx b/apps/web/pages/auth/signin.tsx index 2d77ce00ad..1cc57bcf35 100644 --- a/apps/web/pages/auth/signin.tsx +++ b/apps/web/pages/auth/signin.tsx @@ -95,11 +95,13 @@ export default function SignInPage() { )} - - - Create an account - - + {!process.env.NEXT_PUBLIC_SIGNUP_DISABLED && ( + + + Create an account + + + )} diff --git a/apps/web/pages/auth/signup.tsx b/apps/web/pages/auth/signup.tsx index 459af04476..5bddcf9c1f 100644 --- a/apps/web/pages/auth/signup.tsx +++ b/apps/web/pages/auth/signup.tsx @@ -32,142 +32,171 @@ export default function SignUpPage() { }; return ( -
-
- {error && ( -
-
-
-
-
-

An error occurred when logging you in

-
-

{error}

-
-
+ {process.env.NEXT_PUBLIC_SIGNUP_DISABLED ? ( +
+
+
+
+ snoopForms logo
-
- )} -
-
- snoopForms logo -
- -
-

Finally solid open-source forms 🤸

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- -
- - -
- Already have an account?{" "} - - Log in. - -
- {(process.env.NEXT_PUBLIC_TERMS_URL || process.env.NEXT_PUBLIC_PRIVACY_URL) && ( -
- By clicking "Sign Up", you agree to our -
- {process.env.NEXT_PUBLIC_TERMS_URL && ( - - terms of service - - )} - {process.env.NEXT_PUBLIC_TERMS_URL && process.env.NEXT_PUBLIC_PRIVACY_URL && ( - and - )} - {process.env.NEXT_PUBLIC_PRIVACY_URL && ( - - privacy policy - - )} - .
- We'll occasionally send you account related emails. -
- )} -
-
+
+

Sign up disabled

+

+ The account creation is disabled in this instance. Please contact the site administrator to + create an account. +

+
+
-
+ ) : ( +
+
+ {error && ( +
+
+
+
+
+

+ An error occurred when logging you in +

+
+

{error}

+
+
+
+
+ )} + +
+
+ snoopForms logo +
+ +
+

Finally solid open-source forms 🤸

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ + +
+ Already have an account?{" "} + + Log in. + +
+ {(process.env.NEXT_PUBLIC_TERMS_URL || process.env.NEXT_PUBLIC_PRIVACY_URL) && ( +
+ By clicking "Sign Up", you agree to our +
+ {process.env.NEXT_PUBLIC_TERMS_URL && ( + + terms of service + + )} + {process.env.NEXT_PUBLIC_TERMS_URL && process.env.NEXT_PUBLIC_PRIVACY_URL && ( + and + )} + {process.env.NEXT_PUBLIC_PRIVACY_URL && ( + + privacy policy + + )} + .
+ We'll occasionally send you account related emails. +
+ )} +
+
+
+
+
+
+
+ )} ); } diff --git a/turbo.json b/turbo.json index 5e2a3f2bb2..1e813efc43 100644 --- a/turbo.json +++ b/turbo.json @@ -14,6 +14,7 @@ "NEXT_PUBLIC_PASSWORD_RESET_DISABLED", "NEXT_PUBLIC_PRIVACY_URL", "NEXT_PUBLIC_PRIVACY_URL", + "NEXT_PUBLIC_SIGNUP_DISABLED", "NEXT_PUBLIC_TERMS_URL", "POSTHOG_API_HOST", "POSTHOG_API_KEY",