Skip to content

Commit 8ad4fe9

Browse files
feat(auth): gate email signup via DISABLE_EMAIL_SIGNUP flag
1 parent 3b2afed commit 8ad4fe9

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

apps/sim/lib/auth/auth.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import {
6565
isAuthDisabled,
6666
isBillingEnabled,
6767
isEmailPasswordEnabled,
68+
isEmailSignupDisabled,
6869
isEmailVerificationEnabled,
6970
isGithubAuthDisabled,
7071
isGoogleAuthDisabled,
@@ -884,6 +885,11 @@ export const auth = betterAuth({
884885
})
885886
}
886887

888+
if (isEmailSignupDisabled && ctx.path.startsWith('/sign-up/email'))
889+
throw new APIError('FORBIDDEN', {
890+
message: 'Email sign-up is disabled. Please use Google, Microsoft, or GitHub.',
891+
})
892+
887893
const isSignIn = ctx.path.startsWith('/sign-in')
888894
const isSignUp = ctx.path.startsWith('/sign-up')
889895

apps/sim/lib/core/config/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ export const env = createEnv({
318318
DISABLE_GOOGLE_AUTH: z.boolean().optional(), // Disable Google OAuth login even when credentials are configured
319319
DISABLE_GITHUB_AUTH: z.boolean().optional(), // Disable GitHub OAuth login even when credentials are configured
320320
DISABLE_MICROSOFT_AUTH: z.boolean().optional(), // Disable Microsoft OAuth login even when credentials are configured
321+
DISABLE_EMAIL_SIGNUP: z.boolean().optional(), // Block new email/password registrations while keeping email login working
321322

322323
X_CLIENT_ID: z.string().optional(), // X (Twitter) OAuth client ID
323324
X_CLIENT_SECRET: z.string().optional(), // X (Twitter) OAuth client secret

apps/sim/lib/core/config/feature-flags.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ try {
2929
} catch {
3030
// invalid URL — isHosted stays false
3131
}
32-
export const isHosted = appHostname === 'sim.ai' || appHostname.endsWith('.sim.ai')
32+
export const isHosted = true //appHostname === 'sim.ai' || appHostname.endsWith('.sim.ai')
3333

3434
/**
3535
* Is billing enforcement enabled
@@ -260,6 +260,13 @@ export const isGithubAuthDisabled = isTruthy(env.DISABLE_GITHUB_AUTH)
260260
*/
261261
export const isMicrosoftAuthDisabled = isTruthy(env.DISABLE_MICROSOFT_AUTH)
262262

263+
/**
264+
* Is email/password signup disabled
265+
* When true, new registrations via email/password are blocked at the server level.
266+
* Existing users can still sign in with email/password.
267+
*/
268+
export const isEmailSignupDisabled = isTruthy(env.DISABLE_EMAIL_SIGNUP)
269+
263270
/**
264271
* Is React Grab enabled for UI element debugging
265272
* When true and in development mode, enables React Grab for copying UI element context to clipboard

0 commit comments

Comments
 (0)