@salesforcedevs/dx-components 1.2.7-avatar-button-1 → 1.2.7-avatar-button-3
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
|
@@ -227,15 +227,17 @@ export default class AvatarButton extends LightningElement {
|
|
|
227
227
|
private handleSsoLogin = async (event: Event) => {
|
|
228
228
|
const { userInfo } = (event as CustomEvent).detail;
|
|
229
229
|
const token = userInfo?.access_token;
|
|
230
|
+
const isAlreadyLoading = this.isLoading;
|
|
230
231
|
|
|
231
232
|
// `token` should always be defined if an SSO login occurs, but we check for extra safety
|
|
232
233
|
if (token) {
|
|
233
234
|
this.isLoading = true;
|
|
235
|
+
|
|
234
236
|
// If an SSO login occurred and we have an SSO access token, we want to start using
|
|
235
237
|
// it rather than some other non-linked access token, for the "seamless SSO"
|
|
236
238
|
// experience
|
|
237
239
|
try {
|
|
238
|
-
await fetch(TBID_API_TOKEN_URL, {
|
|
240
|
+
const tokenResponse = await fetch(TBID_API_TOKEN_URL, {
|
|
239
241
|
method: "POST",
|
|
240
242
|
headers: {
|
|
241
243
|
"Content-Type": "application/json"
|
|
@@ -244,17 +246,19 @@ export default class AvatarButton extends LightningElement {
|
|
|
244
246
|
token
|
|
245
247
|
})
|
|
246
248
|
});
|
|
247
|
-
|
|
249
|
+
if (tokenResponse.ok) {
|
|
250
|
+
this.platformEventsSubscribe();
|
|
251
|
+
this.trackLoginSuccess();
|
|
252
|
+
}
|
|
248
253
|
} catch (ex) {
|
|
249
254
|
console.error(`Attempt to update token failed: ${ex}`);
|
|
250
255
|
}
|
|
251
|
-
|
|
252
|
-
this.trackLoginSuccess();
|
|
253
256
|
}
|
|
254
257
|
|
|
255
|
-
if (userInfo) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
+
if (userInfo && !isAlreadyLoading) {
|
|
259
|
+
// TODO: This sucks and we will have to raise an issue with the TBID team, but for some reason the
|
|
260
|
+
// SSO login userInfo payload is missing photos for the user, so we have to re-request it on login.
|
|
261
|
+
this.requestUserInfo();
|
|
258
262
|
}
|
|
259
263
|
|
|
260
264
|
this.isLoading = false;
|
|
@@ -342,7 +346,17 @@ export default class AvatarButton extends LightningElement {
|
|
|
342
346
|
// uncleanUserInfo may have undefined values which we don't want in the final product
|
|
343
347
|
if (val && val !== "undefined") {
|
|
344
348
|
// Also a little extra safety to make sure we aren't injecting anything unsafe...
|
|
345
|
-
|
|
349
|
+
let cleanVal = escapeHtml(val);
|
|
350
|
+
|
|
351
|
+
if (key === "username" && typeof val === "string") {
|
|
352
|
+
// Design requests that we not show the @trailblazer.me part of the username
|
|
353
|
+
const regExpMatch = val.match("(.*)@trailblazer.me$");
|
|
354
|
+
if (regExpMatch && regExpMatch[1]) {
|
|
355
|
+
cleanVal = regExpMatch[1];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
cleanUserInfo[key as keyof UserInfo] = cleanVal;
|
|
346
360
|
}
|
|
347
361
|
});
|
|
348
362
|
|