The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
feat: disable oauth signup when DISABLE_SIGNUP is true
Navindu Amarakoon78a1ee2af0dd
diff --git a/apps/web/src/components/forms/signin.tsx b/apps/web/src/components/forms/signin.tsxindex 0d7dd723f..95dc6f9af 100644--- a/apps/web/src/components/forms/signin.tsx+++ b/apps/web/src/components/forms/signin.tsx@@ -24,6 +24,7 @@ const ERROR_MESSAGES: Partial<Record<keyof typeof ErrorCode, string>> = {'This account appears to be using a social login method, please sign in using that method',[ErrorCode.INCORRECT_TWO_FACTOR_CODE]: 'The two-factor authentication code provided is incorrect',[ErrorCode.INCORRECT_TWO_FACTOR_BACKUP_CODE]: 'The backup code provided is incorrect',+ [ErrorCode.SIGNUP_DISABLED]: 'Creating new accounts is currently disabled',};const TwoFactorEnabledErrorCode = ErrorCode.TWO_FACTOR_MISSING_CREDENTIALS;@@ -146,6 +147,7 @@ export const SignInForm = ({ className }: SignInFormProps) => {try {await signIn('google', { callbackUrl: LOGIN_REDIRECT_PATH });} catch (err) {+ console.error(err);toast({title: 'An unknown error occurred',description:diff --git a/packages/lib/next-auth/auth-options.ts b/packages/lib/next-auth/auth-options.tsindex 6d59b0666..1d900c391 100644--- a/packages/lib/next-auth/auth-options.ts+++ b/packages/lib/next-auth/auth-options.ts@@ -162,5 +162,15 @@ export const NEXT_AUTH_OPTIONS: AuthOptions = {return session;},++ async signIn({ user }) {+ if (process.env.NEXT_PUBLIC_DISABLE_SIGNUP === 'true') {+ const userData = await getUserByEmail({ email: user.email! });++ return !!userData;+ } else {+ return true;+ }+ },},};diff --git a/packages/lib/next-auth/error-codes.ts b/packages/lib/next-auth/error-codes.tsindex c3dfafece..f69206456 100644--- a/packages/lib/next-auth/error-codes.ts+++ b/packages/lib/next-auth/error-codes.ts@@ -19,4 +19,5 @@ export const ErrorCode = {INCORRECT_PASSWORD: 'INCORRECT_PASSWORD',MISSING_ENCRYPTION_KEY: 'MISSING_ENCRYPTION_KEY',MISSING_BACKUP_CODE: 'MISSING_BACKUP_CODE',+ SIGNUP_DISABLED: 'SIGNUP_DISABLED',} as const;diff --git a/packages/tsconfig/process-env.d.ts b/packages/tsconfig/process-env.d.tsindex 717f13ade..7169120c8 100644--- a/packages/tsconfig/process-env.d.ts+++ b/packages/tsconfig/process-env.d.ts@@ -55,6 +55,8 @@ declare namespace NodeJS {NEXT_PRIVATE_SMTP_FROM_NAME?: string;NEXT_PRIVATE_SMTP_FROM_ADDRESS?: string;+ NEXT_PUBLIC_DISABLE_SIGNUP?: string;+/*** Vercel environment variables*/