diff --git a/packages/lib/server/username.ts b/packages/lib/server/username.ts index 0cd23bad78..cc5abc0176 100644 --- a/packages/lib/server/username.ts +++ b/packages/lib/server/username.ts @@ -181,12 +181,11 @@ const usernameCheckForSignup = async ({ const user = await prisma.user.findFirst({ where: { email, - // Simply remove it when we drop organizationId column - organizationId: null, }, select: { id: true, username: true, + organizationId: true, }, }); @@ -206,13 +205,15 @@ const usernameCheckForSignup = async ({ // When we invite an email, that doesn't match the orgAutoAcceptEmail, we create a user with organizationId=null. // The only way to differentiate b/w 'a new email that was invited to an Org' and 'a user that was created using regular signup' is to check if the user is a member of an org. + // If username is in global namespace if (!userIsAMemberOfAnOrg) { response.available = false; + // There are no premium users outside an organization only + response.premium = await isPremiumUserName(username); } - } - - if (await isPremiumUserName(username)) { - response.premium = true; + } else { + // If user isn't found, it's a new signup and that can't be of an organization + response.premium = await isPremiumUserName(username); } // get list of similar usernames in the db