fix: organization user shouldn't be asked for payment for a premium username (#13535)

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
This commit is contained in:
Hariom Balhara
2024-02-08 16:46:21 +00:00
committed by GitHub
co-authored by Joe Au-Yeung
parent 1293588ac4
commit 473012f2c0
+7 -6
View File
@@ -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