Skip to content

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

return only emails instead of returning the whole user

adilson3e39336b8889
diff --git a/backend/src/services/secret-sharing/secret-sharing-service.ts b/backend/src/services/secret-sharing/secret-sharing-service.ts
index 61f240e18b..cf7533a8c5 100644
--- a/backend/src/services/secret-sharing/secret-sharing-service.ts
+++ b/backend/src/services/secret-sharing/secret-sharing-service.ts
@@ -161,14 +161,14 @@ export const secretSharingServiceFactory = ({
// makes sure the user is not sharing secrets with users that are not registered on Infisical without knowing it
if (emails && emails.length > 0 && accessType !== SecretSharingAccessType.Organization && !allowExternalEmails) {
- const platformUsers = await userDAL.findUsersByEmails(emails);
+ const platformUsers = await userDAL.getVerifiedEmailsByEmailList(emails);
const platformEmailSet = new Set(platformUsers.map((u) => u.email!.toLowerCase()));
const hasUnregisteredEmail = emails.some((e) => !platformEmailSet.has(e.toLowerCase()));
if (hasUnregisteredEmail) {
throw new BadRequestError({
message:
- "One or more emails are not registered on Infisical! Use allowExternalEmails to share secrets with users outside of Infisical."
+ "One or more recipient emails are not registered on Infisical. Set allowExternalEmails to share secrets with users outside Infisical."
});
}
}
diff --git a/backend/src/services/user/user-dal.ts b/backend/src/services/user/user-dal.ts
index 4a5e2428b0..7375572752 100644
--- a/backend/src/services/user/user-dal.ts
+++ b/backend/src/services/user/user-dal.ts
@@ -31,7 +31,7 @@ export const userDALFactory = (db: TDbClient) => {
isEmailVerified: true
});
- const findUsersByEmails = async (emails: string[], tx?: Knex) => {
+ const getVerifiedEmailsByEmailList = async (emails: string[], tx?: Knex) => {
if (emails.length === 0) return [];
return (tx || db.replicaNode())(TableName.Users)
@@ -39,7 +39,8 @@ export const userDALFactory = (db: TDbClient) => {
`lower("email") IN (${emails.map(() => "?").join(",")})`,
emails.map((e) => e.toLowerCase())
)
- .where({ isEmailVerified: true });
+ .where({ isEmailVerified: true })
+ .select("email");
};
const getUsersByFilter = async ({
@@ -276,6 +277,6 @@ export const userDALFactory = (db: TDbClient) => {
getUsersByFilter,
findAllMyAccounts,
findUserByEmail,
- findUsersByEmails
+ getVerifiedEmailsByEmailList
};
};