Skip to content

Commit 077093f

Browse files
committed
fix userPrincipleName/mail encoding
1 parent 6082aba commit 077093f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/mgt-components/src/graph/graph.people.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ export const getEmailFromGraphEntity = (entity: IDynamicPerson): string => {
218218

219219
if (user?.mail) {
220220
return extractEmailAddress(user.mail);
221-
} else if (person.scoredEmailAddresses?.length) {
221+
} else if (person?.scoredEmailAddresses?.length) {
222222
return extractEmailAddress(person.scoredEmailAddresses[0].address);
223-
} else if (contact.emailAddresses?.length) {
223+
} else if (contact?.emailAddresses?.length) {
224224
return extractEmailAddress(contact.emailAddresses[0].address);
225225
}
226226
return null;

packages/mgt-components/src/graph/graph.photos.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ export const getUserPhoto = async (graph: IGraph, userId: string): Promise<strin
120120
let cache: CacheStore<CachePhoto>;
121121
let photoDetails: CachePhoto;
122122

123+
const encodedUser = `${userId.replace(/#/g, '%2523')}`;
124+
123125
if (getIsPhotosCacheEnabled()) {
124126
cache = CacheService.getCache<CachePhoto>(schemas.photos, schemas.photos.stores.users);
125127
photoDetails = await cache.getValue(userId);
@@ -144,7 +146,7 @@ export const getUserPhoto = async (graph: IGraph, userId: string): Promise<strin
144146
}
145147
}
146148
// if there is a photo in the cache, we got here because it was stale
147-
photoDetails = photoDetails || (await getPhotoForResource(graph, `users/${userId}`, anyUserValidPhotoScopes));
149+
photoDetails = photoDetails || (await getPhotoForResource(graph, `users/${encodedUser}`, anyUserValidPhotoScopes));
148150
if (getIsPhotosCacheEnabled() && photoDetails) {
149151
await cache.putValue(userId, photoDetails);
150152
}

0 commit comments

Comments
 (0)