@salesforcedevs/dx-components 0.59.0-avatar-button-8 → 0.59.0-avatar-button-11

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": "0.59.0-avatar-button-8",
3
+ "version": "0.59.0-avatar-button-11",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -56,10 +56,12 @@ export default class AvatarButton extends LightningElement {
56
56
  window.addEventListener("tbid-login", this.handleSsoLogin);
57
57
  window.addEventListener("tbid-logout", this.handleSsoLogout);
58
58
 
59
- // Whenever this component is added to the DOM, immediately request user info; if the user is logged in
60
- // and we receive the info, this component will display the avatar UI; otherwise, it will display the login
61
- // button.
62
- this.requestUserInfo();
59
+ // Whenever this component is added to the DOM and there is not an SFIDWidget present, immediately request
60
+ // user info; if the user is logged in and we receive the info, this component will display the avatar UI;
61
+ // otherwise, it will display the login button.
62
+ if (!window.SFIDWidget) {
63
+ this.requestUserInfo();
64
+ }
63
65
  }
64
66
 
65
67
  disconnectedCallback() {
@@ -78,11 +80,11 @@ export default class AvatarButton extends LightningElement {
78
80
  // defer to the SFIDWidget. This will ensure that the SSO session is logged out as
79
81
  // well.
80
82
  window.SFIDWidget.logout();
83
+ } else {
84
+ // Always clear the session token; if not SSO logout, this will also revoke the token with
85
+ // TBID; if SSO logout, that step is already taken care of
86
+ fetch(`${TBID_API_LOGOUT_URL}?isSsoLogout=${isSsoLogout}`); // no need to await this
81
87
  }
82
-
83
- // Always clear the session token; if not SSO logout, this will also revoke the token with
84
- // TBID; if SSO logout, that step is already taken care of
85
- fetch(`${TBID_API_LOGOUT_URL}?isSsoLogout=${isSsoLogout}`); // no need to await this
86
88
  };
87
89
 
88
90
  // This will only be called for "seamless SSO" login by the embedded login widget (SFIDWidget) on the website, if it exists.
@@ -103,6 +105,9 @@ export default class AvatarButton extends LightningElement {
103
105
  try {
104
106
  await fetch(TBID_API_TOKEN_URL, {
105
107
  method: "POST",
108
+ headers: {
109
+ "Content-Type": "application/json"
110
+ },
106
111
  body: JSON.stringify({
107
112
  token
108
113
  })