@salesforcedevs/dx-components 1.2.7-avatar-button-2 → 1.2.7-avatar-button-4
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,39 +227,40 @@ 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
|
-
if (token) {
|
|
233
|
-
|
|
233
|
+
if (!token) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
234
236
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
237
|
+
// If an SSO login occurred and we have an SSO access token, we want to start using
|
|
238
|
+
// it rather than some other non-linked access token, for the "seamless SSO"
|
|
239
|
+
// experience
|
|
240
|
+
try {
|
|
241
|
+
const tokenResponse = await fetch(TBID_API_TOKEN_URL, {
|
|
242
|
+
method: "POST",
|
|
243
|
+
headers: {
|
|
244
|
+
"Content-Type": "application/json"
|
|
245
|
+
},
|
|
246
|
+
body: JSON.stringify({
|
|
247
|
+
token
|
|
248
|
+
})
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
if (tokenResponse.ok) {
|
|
252
|
+
this.platformEventsSubscribe();
|
|
253
|
+
this.trackLoginSuccess();
|
|
254
|
+
|
|
255
|
+
if (!isAlreadyLoading) {
|
|
256
|
+
// TODO: This sucks and we will have to raise an issue with the TBID team, but for some reason the
|
|
257
|
+
// SSO login userInfo payload is missing photos for the user, so we have to re-request it on login.
|
|
258
|
+
this.requestUserInfo();
|
|
251
259
|
}
|
|
252
|
-
} catch (ex) {
|
|
253
|
-
console.error(`Attempt to update token failed: ${ex}`);
|
|
254
260
|
}
|
|
261
|
+
} catch (ex) {
|
|
262
|
+
console.error(`Attempt to update token failed: ${ex}`);
|
|
255
263
|
}
|
|
256
|
-
|
|
257
|
-
if (userInfo) {
|
|
258
|
-
this.updateAvatarWithUserInfo(userInfo);
|
|
259
|
-
this._didReceiveUserInfo = true;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
this.isLoading = false;
|
|
263
264
|
};
|
|
264
265
|
|
|
265
266
|
private handleComponentLogin = (event: MouseEvent) => {
|