@salesforcedevs/dx-components 0.59.0-avatar-button-12 → 0.59.0-avatar-button-15
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/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -94,19 +94,22 @@ 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 =
|
|
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*
|
|
104
|
-
// defer to the SFIDWidget. This will ensure that the SSO
|
|
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
|
|
109
109
|
// TBID; if SSO logout, that step is already taken care of
|
|
110
|
+
const ifr = document.createElement('iframe');
|
|
111
|
+
ifr.setAttribute('src', 'https://dev1-trailblazer-identity.cs192.force.com/secur/logout.jsp');
|
|
112
|
+
document.body.appendChild(ifr);
|
|
110
113
|
fetch(`${TBID_API_LOGOUT_URL}?isSsoLogout=${isSsoLogout}`); // no need to await this
|
|
111
114
|
}
|
|
112
115
|
};
|
|
@@ -118,7 +121,8 @@ export default class AvatarButton extends LightningElement {
|
|
|
118
121
|
|
|
119
122
|
// This will only be called for "seamless SSO" login by the embedded login widget (SFIDWidget) on the website, if it exists.
|
|
120
123
|
private handleSsoLogin = async (event: Event) => {
|
|
121
|
-
const
|
|
124
|
+
const { userInfo } = (event as CustomEvent).detail;
|
|
125
|
+
const token = userInfo?.access_token;
|
|
122
126
|
|
|
123
127
|
// `token` should always be defined if an SSO login occurs, but we check for extra safety
|
|
124
128
|
if (token) {
|
|
@@ -136,16 +140,15 @@ export default class AvatarButton extends LightningElement {
|
|
|
136
140
|
token
|
|
137
141
|
})
|
|
138
142
|
});
|
|
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
143
|
} catch (ex) {
|
|
144
|
-
|
|
145
|
-
this.updateAvatarWithUserInfo(this.userInfo);
|
|
146
|
-
console.error(ex);
|
|
144
|
+
console.error(`Attempt to update token failed: ${ex}`);
|
|
147
145
|
}
|
|
148
146
|
}
|
|
147
|
+
|
|
148
|
+
if (userInfo) {
|
|
149
|
+
this.updateAvatarWithUserInfo(userInfo);
|
|
150
|
+
this._didReceiveUserInfo = true;
|
|
151
|
+
}
|
|
149
152
|
};
|
|
150
153
|
|
|
151
154
|
private handleComponentLogin = () => {
|
|
@@ -183,7 +186,7 @@ export default class AvatarButton extends LightningElement {
|
|
|
183
186
|
}
|
|
184
187
|
} catch (ex) {
|
|
185
188
|
// TODO: Something not directly related to auth went wrong. Unsure what to do here.
|
|
186
|
-
console.error(
|
|
189
|
+
console.error(`Could not request user info: ${ex}`);
|
|
187
190
|
}
|
|
188
191
|
|
|
189
192
|
this.isLoading = false;
|