@salesforcedevs/dx-components 0.59.0-avatar-button-12 → 0.59.0-avatar-button-13

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-12",
3
+ "version": "0.59.0-avatar-button-13",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -94,15 +94,15 @@ export default class AvatarButton extends LightningElement {
94
94
  }
95
95
 
96
96
  // This handles logout from within this component, rather than from SSO via the SFIDWidget.
97
- private handleLogout = async (isSsoLogout: boolean) => {
97
+ private handleLogout = (isSsoLogout: boolean) => {
98
98
  this._didReceiveUserInfo = false;
99
99
  this.isLoading = false;
100
100
  this.updateAvatarWithUserInfo({}); // clear old info
101
101
 
102
- if (!isSsoLogout && window.SFIDWidget) {
103
- // If the SFIDWidget is around and logout was not *already* triggered by SSO logout,
104
- // defer to the SFIDWidget. This will ensure that the SSO session is logged out as
105
- // well.
102
+ if (!isSsoLogout && window.SFIDWidget?.openid_response) {
103
+ // If the SFIDWidget is around and has an access token, and if logout was not *already*
104
+ // triggered by SSO logout, defer to the SFIDWidget. This will ensure that the SSO
105
+ // session is logged out as well.
106
106
  window.SFIDWidget.logout();
107
107
  } else {
108
108
  // Always clear the session token; if not SSO logout, this will also revoke the token with
@@ -118,7 +118,8 @@ export default class AvatarButton extends LightningElement {
118
118
 
119
119
  // This will only be called for "seamless SSO" login by the embedded login widget (SFIDWidget) on the website, if it exists.
120
120
  private handleSsoLogin = async (event: Event) => {
121
- const token = (event as CustomEvent).detail.userInfo?.access_token;
121
+ const { userInfo } = (event as CustomEvent).detail;
122
+ const token = userInfo?.access_token;
122
123
 
123
124
  // `token` should always be defined if an SSO login occurs, but we check for extra safety
124
125
  if (token) {
@@ -136,16 +137,14 @@ export default class AvatarButton extends LightningElement {
136
137
  token
137
138
  })
138
139
  });
139
-
140
- // Unfortunately, the user info provided by the SFIDWidget on SSO login does not contain
141
- // image URLs, so we also have to request it manually again
142
- this.requestUserInfo();
143
140
  } catch (ex) {
144
- // If the request fails for some reason, fall back to whatever we've got
145
- this.updateAvatarWithUserInfo(this.userInfo);
146
- console.error(ex);
141
+ console.error(`Attempt to update token failed: ${ex}`);
147
142
  }
148
143
  }
144
+
145
+ if (userInfo) {
146
+ this.updateAvatarWithUserInfo(userInfo);
147
+ }
149
148
  };
150
149
 
151
150
  private handleComponentLogin = () => {
@@ -183,7 +182,7 @@ export default class AvatarButton extends LightningElement {
183
182
  }
184
183
  } catch (ex) {
185
184
  // TODO: Something not directly related to auth went wrong. Unsure what to do here.
186
- console.error("Invalid response received from TBID API, aborting.");
185
+ console.error(`Could not request user info: ${ex}`);
187
186
  }
188
187
 
189
188
  this.isLoading = false;