Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

patch invite only

Maidul Islamec34572087b8
diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts
index 7d46580a12..f7555248ad 100644
--- a/backend/src/config/index.ts
+++ b/backend/src/config/index.ts
@@ -5,7 +5,7 @@ const client = new InfisicalClient({
});
export const getPort = async () => (await client.getSecret('PORT')).secretValue || 4000;
-export const getInviteOnlySignup = async () => (await client.getSecret('INVITE_ONLY_SIGNUP')).secretValue == undefined ? false : (await client.getSecret('INVITE_ONLY_SIGNUP')).secretValue;
+export const getInviteOnlySignup = async () => (await client.getSecret('INVITE_ONLY_SIGNUP')).secretValue === 'true'
export const getEncryptionKey = async () => (await client.getSecret('ENCRYPTION_KEY')).secretValue;
export const getSaltRounds = async () => parseInt((await client.getSecret('SALT_ROUNDS')).secretValue) || 10;
export const getJwtAuthLifetime = async () => (await client.getSecret('JWT_AUTH_LIFETIME')).secretValue || '10d';
diff --git a/backend/src/controllers/v1/signupController.ts b/backend/src/controllers/v1/signupController.ts
index 193699c155..e5af676b3c 100644
--- a/backend/src/controllers/v1/signupController.ts
+++ b/backend/src/controllers/v1/signupController.ts
@@ -21,14 +21,6 @@ export const beginEmailSignup = async (req: Request, res: Response) => {
try {
email = req.body.email;
- if (await getInviteOnlySignup()) {
- // Only one user can create an account without being invited. The rest need to be invited in order to make an account
- const userCount = await User.countDocuments({})
- if (userCount != 0) {
- throw BadRequestError({ message: "New user sign ups are not allowed at this time. You must be invited to sign up." })
- }
- }
-
const user = await User.findOne({ email }).select('+publicKey');
if (user && user?.publicKey) {
// case: user has already completed account
@@ -74,6 +66,14 @@ export const verifyEmailSignup = async (req: Request, res: Response) => {
});
}
+ if (await getInviteOnlySignup()) {
+ // Only one user can create an account without being invited. The rest need to be invited in order to make an account
+ const userCount = await User.countDocuments({})
+ if (userCount != 0) {
+ throw BadRequestError({ message: "New user sign ups are not allowed at this time. You must be invited to sign up." })
+ }
+ }
+
// verify email
if (await getSmtpConfigured()) {
await checkEmailVerification({