@salesforcedevs/dx-components 1.2.6-avatar-button-3 → 1.2.6-avatar-button-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -12,9 +12,8 @@ const TBID_PROFILE_URL = `${TBID_BASE_URL}/id`;
|
|
|
12
12
|
const TBID_IFRAME_URL = `${TBID_BASE_URL}/secur/logout.jsp`;
|
|
13
13
|
|
|
14
14
|
// API URLs:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}/tbid`;
|
|
15
|
+
// TODO: Switch this to env variable once we're out of dev
|
|
16
|
+
const TBID_API_BASE_URL = "https://development.developer.salesforce.com/tbid";
|
|
18
17
|
const TBID_API_LOGOUT_URL = `${TBID_API_BASE_URL}/logout`;
|
|
19
18
|
const TBID_API_USERINFO_URL = `${TBID_API_BASE_URL}/userinfo`;
|
|
20
19
|
const TBID_API_LOGIN_URL = `${TBID_API_BASE_URL}/dologin`;
|
|
@@ -312,38 +311,44 @@ export default class AvatarButton extends LightningElement {
|
|
|
312
311
|
return;
|
|
313
312
|
}
|
|
314
313
|
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
? `${
|
|
325
|
-
:
|
|
314
|
+
const uncleanNextUserInfo: UserInfo = {};
|
|
315
|
+
uncleanNextUserInfo.avatarImgSrc = userInfo.photos?.thumbnail;
|
|
316
|
+
uncleanNextUserInfo.firstName = userInfo.given_name;
|
|
317
|
+
uncleanNextUserInfo.lastName = userInfo.family_name;
|
|
318
|
+
uncleanNextUserInfo.username = userInfo.preferred_username;
|
|
319
|
+
uncleanNextUserInfo.id = userInfo.user_id;
|
|
320
|
+
uncleanNextUserInfo.orgId = userInfo.organization_id;
|
|
321
|
+
uncleanNextUserInfo.fullName =
|
|
322
|
+
uncleanNextUserInfo.firstName && uncleanNextUserInfo.lastName
|
|
323
|
+
? `${uncleanNextUserInfo.firstName} ${uncleanNextUserInfo.lastName}`
|
|
324
|
+
: uncleanNextUserInfo.firstName ||
|
|
325
|
+
uncleanNextUserInfo.lastName ||
|
|
326
|
+
"";
|
|
326
327
|
|
|
327
328
|
if (userInfo.custom_attributes) {
|
|
328
329
|
// ProfilePictureUrl updates earlier than photos.thumbnail, so we prefer it if it's available here.
|
|
329
|
-
|
|
330
|
+
uncleanNextUserInfo.avatarImgSrc =
|
|
330
331
|
userInfo.custom_attributes.ProfilePictureUrl ||
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
332
|
+
uncleanNextUserInfo.avatarImgSrc;
|
|
333
|
+
uncleanNextUserInfo.company =
|
|
334
|
+
userInfo.custom_attributes.CompanyName;
|
|
335
|
+
uncleanNextUserInfo.relationship =
|
|
334
336
|
userInfo.custom_attributes.RelationshipToSalesforce;
|
|
335
|
-
|
|
337
|
+
uncleanNextUserInfo.role = userInfo.custom_attributes.Role;
|
|
336
338
|
}
|
|
337
339
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
340
|
+
const cleanUserInfo: UserInfo = {};
|
|
341
|
+
Object.entries(uncleanNextUserInfo).forEach(([key, val]) => {
|
|
342
|
+
if (val === "undefined") {
|
|
343
|
+
// Clean away bad JSON string data by skipping these.
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
// Also just a little extra safety to make sure we aren't injecting anything unsafe...
|
|
347
|
+
cleanUserInfo[key as keyof UserInfo] = escapeHtml(val);
|
|
348
|
+
});
|
|
345
349
|
|
|
346
|
-
|
|
350
|
+
// Keep the old info for any values not defined on `cleanUserInfo`
|
|
351
|
+
this.userInfo = defaults(cleanUserInfo, this.userInfo);
|
|
347
352
|
};
|
|
348
353
|
|
|
349
354
|
private requestUserInfo = async () => {
|