feat: add check for People.Read scope in searchContacts

This commit is contained in:
Atef Bellaaj 2025-06-13 10:50:28 +02:00 committed by Danny Avila
parent c9aa10d3d5
commit 1016a33b89
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956

View file

@ -211,7 +211,13 @@ const searchContacts = async (graphClient, query, limit = 10) => {
if (!query || query.trim().length < 2) { if (!query || query.trim().length < 2) {
return []; return [];
} }
if (
process.env.OPENID_GRAPH_SCOPES &&
!process.env.OPENID_GRAPH_SCOPES.toLowerCase().includes('people.read')
) {
logger.warn('[searchContacts] People.Read scope is not enabled, skipping contact search');
return [];
}
// Reason: Search only for OrganizationUser (person) type, not groups // Reason: Search only for OrganizationUser (person) type, not groups
const filter = "personType/subclass eq 'OrganizationUser'"; const filter = "personType/subclass eq 'OrganizationUser'";