From 1a68b688e4ce1120e550a809ad7cac0832d1237a Mon Sep 17 00:00:00 2001 From: Tania Sanz Date: Tue, 12 May 2026 21:18:07 +0200 Subject: [PATCH] feat: hide signup link from login when DISABLE_SIGNUPS is set Expose `signupsDisabled` on the public `GET /config` endpoint so the dashboard can reflect the API's `DISABLE_SIGNUPS` env flag. - Conditionally hide the "Sign up" link on the login page when signups are disabled, so visitors don't get routed to a form that always rejects with "New user signups are currently disabled". - Replace the signup form with a friendly "Signups are disabled" notice if a visitor navigates to /auth/signup directly. Pure UX patch. Does not change the signup endpoint's existing behavior (200 with success:false when disabled) and exposes only the signup-disabled flag - no secrets or admin-only env state. --- apps/api/src/controllers/Config.ts | 4 + apps/web/src/lib/hooks/useConfig.ts | 1 + apps/web/src/pages/auth/login.tsx | 15 +- apps/web/src/pages/auth/signup.tsx | 281 +++++++++++++++------------- 4 files changed, 163 insertions(+), 138 deletions(-) diff --git a/apps/api/src/controllers/Config.ts b/apps/api/src/controllers/Config.ts index 99e45cb3..637755e9 100644 --- a/apps/api/src/controllers/Config.ts +++ b/apps/api/src/controllers/Config.ts @@ -5,6 +5,7 @@ import { API_URI, AWS_SES_REGION, DASHBOARD_URI, + DISABLE_SIGNUPS, GITHUB_OAUTH_ENABLED, GOOGLE_OAUTH_ENABLED, LANDING_URI, @@ -47,6 +48,9 @@ export class Config { github: GITHUB_OAUTH_ENABLED, google: GOOGLE_OAUTH_ENABLED, }, + signup: { + signupsDisabled: DISABLE_SIGNUPS, + }, email: { trackingToggleEnabled: TRACKING_TOGGLE_ENABLED, }, diff --git a/apps/web/src/lib/hooks/useConfig.ts b/apps/web/src/lib/hooks/useConfig.ts index 85f870d1..ba9b4aca 100644 --- a/apps/web/src/lib/hooks/useConfig.ts +++ b/apps/web/src/lib/hooks/useConfig.ts @@ -12,6 +12,7 @@ export interface ConfigResponse { billing: {enabled: boolean}; storage: {s3Enabled: boolean}; authProviders: {github: boolean; google: boolean}; + signup: {signupsDisabled: boolean}; email: {trackingToggleEnabled: boolean}; smtp: { enabled: boolean; diff --git a/apps/web/src/pages/auth/login.tsx b/apps/web/src/pages/auth/login.tsx index 181e8e33..cece7ab0 100644 --- a/apps/web/src/pages/auth/login.tsx +++ b/apps/web/src/pages/auth/login.tsx @@ -63,6 +63,7 @@ export default function Login() { github: config?.features.authProviders.github ?? false, google: config?.features.authProviders.google ?? false, }; + const signupsDisabled = config?.features.signup.signupsDisabled ?? false; async function onSubmit(values: z.infer) { try { @@ -295,12 +296,14 @@ export default function Login() { )} -

- Don't have an account?{' '} - - Sign up - -

+ {!signupsDisabled && ( +

+ Don't have an account?{' '} + + Sign up + +

+ )} diff --git a/apps/web/src/pages/auth/signup.tsx b/apps/web/src/pages/auth/signup.tsx index e04ee4a4..323625bc 100644 --- a/apps/web/src/pages/auth/signup.tsx +++ b/apps/web/src/pages/auth/signup.tsx @@ -48,6 +48,7 @@ export default function Signup() { github: config?.features.authProviders.github ?? false, google: config?.features.authProviders.google ?? false, }; + const signupsDisabled = config?.features.signup.signupsDisabled ?? false; async function onSubmit(values: z.infer) { try { @@ -96,144 +97,160 @@ export default function Signup() { -
- { - e.preventDefault(); - void form.handleSubmit(onSubmit)(e); - }} - className="p-8" - > -
-
-

Create an account

-

Start sending emails in minutes

-
+ {signupsDisabled ? ( +
+

Signups are disabled

+

+ New account registration is currently disabled on this instance. Please contact your administrator if you + believe this is a mistake. +

+ + Back to log in + +
+ ) : ( + + { + e.preventDefault(); + void form.handleSubmit(onSubmit)(e); + }} + className="p-8" + > +
+
+

Create an account

+

Start sending emails in minutes

+
- {(oauthConfig.github || oauthConfig.google) && ( - <> -
- {oauthConfig.google && ( - - )} - {oauthConfig.github && ( - - )} -
-
-
- + {(oauthConfig.github || oauthConfig.google) && ( + <> +
+ {oauthConfig.google && ( + + )} + {oauthConfig.github && ( + + )}
-
- or +
+
+ +
+
+ or +
-
- - )} - -
- ( - - Email - - - - - - )} - /> - - ( - - Password - - - - - + + )} + +
+ ( + + Email + + + + + + )} + /> + + ( + + Password + + + + + + )} + /> +
+ + + {errorMessage && ( + + {errorMessage} + )} - /> -
+ - - {errorMessage && ( - - {errorMessage} - - )} - + - - -

- Already have an account?{' '} - - Log in - -

-
- - +

+ Already have an account?{' '} + + Log in + +

+
+ + + )}