mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
feat: disable oauth signup when DISABLE_SIGNUP is true
This commit is contained in:
@ -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',
|
'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_CODE]: 'The two-factor authentication code provided is incorrect',
|
||||||
[ErrorCode.INCORRECT_TWO_FACTOR_BACKUP_CODE]: 'The backup 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;
|
const TwoFactorEnabledErrorCode = ErrorCode.TWO_FACTOR_MISSING_CREDENTIALS;
|
||||||
@ -146,6 +147,7 @@ export const SignInForm = ({ className }: SignInFormProps) => {
|
|||||||
try {
|
try {
|
||||||
await signIn('google', { callbackUrl: LOGIN_REDIRECT_PATH });
|
await signIn('google', { callbackUrl: LOGIN_REDIRECT_PATH });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
toast({
|
toast({
|
||||||
title: 'An unknown error occurred',
|
title: 'An unknown error occurred',
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -162,5 +162,15 @@ export const NEXT_AUTH_OPTIONS: AuthOptions = {
|
|||||||
|
|
||||||
return session;
|
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;
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -19,4 +19,5 @@ export const ErrorCode = {
|
|||||||
INCORRECT_PASSWORD: 'INCORRECT_PASSWORD',
|
INCORRECT_PASSWORD: 'INCORRECT_PASSWORD',
|
||||||
MISSING_ENCRYPTION_KEY: 'MISSING_ENCRYPTION_KEY',
|
MISSING_ENCRYPTION_KEY: 'MISSING_ENCRYPTION_KEY',
|
||||||
MISSING_BACKUP_CODE: 'MISSING_BACKUP_CODE',
|
MISSING_BACKUP_CODE: 'MISSING_BACKUP_CODE',
|
||||||
|
SIGNUP_DISABLED: 'SIGNUP_DISABLED',
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
2
packages/tsconfig/process-env.d.ts
vendored
2
packages/tsconfig/process-env.d.ts
vendored
@ -55,6 +55,8 @@ declare namespace NodeJS {
|
|||||||
NEXT_PRIVATE_SMTP_FROM_NAME?: string;
|
NEXT_PRIVATE_SMTP_FROM_NAME?: string;
|
||||||
NEXT_PRIVATE_SMTP_FROM_ADDRESS?: string;
|
NEXT_PRIVATE_SMTP_FROM_ADDRESS?: string;
|
||||||
|
|
||||||
|
NEXT_PUBLIC_DISABLE_SIGNUP?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vercel environment variables
|
* Vercel environment variables
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user