Skip to content

Commit b77ad17

Browse files
author
Juha Alhojoki
committed
people picker imageUrl was resolved by user email, when it should be resolved by user's accountName
1 parent b3e253d commit b77ad17

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/services/PeopleSearchService.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,11 @@ export default class SPPeopleSearchService {
229229
switch (element.EntityType) {
230230
case 'User':
231231
let email: string = element.EntityData.Email !== null ? element.EntityData.Email : element.Description;
232+
const accountName = this.getAccountName(element);
232233
return {
233234
id: element.Key,
234235
loginName: element.LoginName ? element.LoginName : element.Key,
235-
imageUrl: this.generateUserPhotoLink(email),
236+
imageUrl: this.generateUserPhotoLink(accountName),
236237
imageInitials: this.getFullNameInitials(element.DisplayText),
237238
text: element.DisplayText, // name
238239
secondaryText: email, // email
@@ -309,6 +310,20 @@ export default class SPPeopleSearchService {
309310
return null;
310311
}
311312

313+
/**
314+
* Gets account name for user, falls back to description
315+
*/
316+
private getAccountName(element: any): string {
317+
const loginName: string = element.LoginName || element.Key;
318+
if (loginName) {
319+
const loginParts: string[] = loginName.split("|");
320+
if (loginParts.length > 0) {
321+
return loginParts[loginParts.length - 1];
322+
}
323+
}
324+
return element.Description || "";
325+
}
326+
312327
/**
313328
* Generates Initials from a full name
314329
*/

0 commit comments

Comments
 (0)