@salesforcedevs/dx-components 1.2.7-avatar-button-1 → 1.2.7-avatar-button-2

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.2.7-avatar-button-1",
3
+ "version": "1.2.7-avatar-button-2",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -231,11 +231,12 @@ export default class AvatarButton extends LightningElement {
231
231
  // `token` should always be defined if an SSO login occurs, but we check for extra safety
232
232
  if (token) {
233
233
  this.isLoading = true;
234
+
234
235
  // If an SSO login occurred and we have an SSO access token, we want to start using
235
236
  // it rather than some other non-linked access token, for the "seamless SSO"
236
237
  // experience
237
238
  try {
238
- await fetch(TBID_API_TOKEN_URL, {
239
+ const tokenResponse = await fetch(TBID_API_TOKEN_URL, {
239
240
  method: "POST",
240
241
  headers: {
241
242
  "Content-Type": "application/json"
@@ -244,12 +245,13 @@ export default class AvatarButton extends LightningElement {
244
245
  token
245
246
  })
246
247
  });
247
- this.platformEventsSubscribe();
248
+ if (tokenResponse.ok) {
249
+ this.platformEventsSubscribe();
250
+ this.trackLoginSuccess();
251
+ }
248
252
  } catch (ex) {
249
253
  console.error(`Attempt to update token failed: ${ex}`);
250
254
  }
251
-
252
- this.trackLoginSuccess();
253
255
  }
254
256
 
255
257
  if (userInfo) {
@@ -342,7 +344,17 @@ export default class AvatarButton extends LightningElement {
342
344
  // uncleanUserInfo may have undefined values which we don't want in the final product
343
345
  if (val && val !== "undefined") {
344
346
  // Also a little extra safety to make sure we aren't injecting anything unsafe...
345
- cleanUserInfo[key as keyof UserInfo] = escapeHtml(val);
347
+ let cleanVal = escapeHtml(val);
348
+
349
+ if (key === "username" && typeof val === "string") {
350
+ // Design requests that we not show the @trailblazer.me part of the username
351
+ const regExpMatch = val.match("(.*)@trailblazer.me$");
352
+ if (regExpMatch && regExpMatch[1]) {
353
+ cleanVal = regExpMatch[1];
354
+ }
355
+ }
356
+
357
+ cleanUserInfo[key as keyof UserInfo] = cleanVal;
346
358
  }
347
359
  });
348
360