Skip to content

Commit cbbd78a

Browse files
mrjasonroyclaude
andcommitted
feat: add DISABLE_EMAIL_SIGN_UP to control email and OAuth signups separately
Previously, DISABLE_SIGN_UP controlled both email and OAuth signups together. This change introduces DISABLE_EMAIL_SIGN_UP to allow more granular control: - DISABLE_EMAIL_SIGN_IN: Disables email/password authentication entirely - DISABLE_EMAIL_SIGN_UP: Disables email/password signups only (allows existing users to sign in) - DISABLE_SIGN_UP: Disables OAuth signups only (Google, GitHub, Microsoft) This enables use cases like: - Allow OAuth signups but block email signups - Require users to authenticate via corporate SSO while blocking email registration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 28a99bf commit cbbd78a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.env.example

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,15 @@ MICROSOFT_TENANT_ID=
7676
MICROSOFT_FORCE_ACCOUNT_SELECTION=
7777

7878
# (Optional)
79-
# Set this to 1 to disable email sign in
79+
# Set this to 1 to disable email/password sign in completely
8080
DISABLE_EMAIL_SIGN_IN=
8181

8282
# (Optional)
83-
# Set this to 1 to disable user sign-ups.
83+
# Set this to 1 to disable email/password sign-ups (still allows sign-in for existing users)
84+
DISABLE_EMAIL_SIGN_UP=
85+
86+
# (Optional)
87+
# Set this to 1 to disable OAuth sign-ups (Google, GitHub, Microsoft)
8488
DISABLE_SIGN_UP=
8589

8690
# (Optional)

src/lib/auth/config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function parseSocialAuthConfigs() {
2828
google?: GoogleConfig;
2929
microsoft?: MicrosoftConfig;
3030
} = {};
31+
// DISABLE_SIGN_UP only applies to OAuth signups, not email signups
3132
const disableSignUp = parseEnvBoolean(process.env.DISABLE_SIGN_UP);
3233

3334
if (process.env.GITHUB_CLIENT_ID && process.env.GITHUB_CLIENT_SECRET) {
@@ -102,8 +103,10 @@ export function getAuthConfig(): AuthConfig {
102103
emailAndPasswordEnabled: process.env.DISABLE_EMAIL_SIGN_IN
103104
? !parseEnvBoolean(process.env.DISABLE_EMAIL_SIGN_IN)
104105
: true,
105-
signUpEnabled: process.env.DISABLE_SIGN_UP
106-
? !parseEnvBoolean(process.env.DISABLE_SIGN_UP)
106+
// signUpEnabled now only applies to email signups
107+
// OAuth signups are controlled separately via DISABLE_SIGN_UP in parseSocialAuthConfigs
108+
signUpEnabled: process.env.DISABLE_EMAIL_SIGN_UP
109+
? !parseEnvBoolean(process.env.DISABLE_EMAIL_SIGN_UP)
107110
: true,
108111
socialAuthenticationProviders: parseSocialAuthConfigs(),
109112
};

0 commit comments

Comments
 (0)