@salesforcedevs/dx-components 0.55.3-alpha-3 → 0.55.3-alpha-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
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
<a href="#" class="inline-link">Switch account</a>
|
|
22
22
|
|
|
|
23
23
|
-->
|
|
24
|
-
<a href={
|
|
24
|
+
<a href="#" onclick={handleLogout} class="inline-link">
|
|
25
|
+
Logout
|
|
26
|
+
</a>
|
|
25
27
|
</div>
|
|
26
28
|
<div class="login-section">
|
|
27
29
|
<span class="login-section-title">Trailblazer.me</span>
|
|
@@ -6,6 +6,7 @@ const TBID_LOGIN_URL =
|
|
|
6
6
|
"https://development.developer.salesforce.com/tbid/dologin";
|
|
7
7
|
const TBID_LOGOUT_URL = `${TBID_BASE_URL}/services/auth/idp/oidc/logout`;
|
|
8
8
|
const TBID_USERINFO_URL = `${TBID_BASE_URL}/services/oauth2/userinfo`;
|
|
9
|
+
const TBID_REVOKE_URL = `${TBID_BASE_URL}/services/oauth2/revoke`;
|
|
9
10
|
|
|
10
11
|
export interface UserInfo {
|
|
11
12
|
avatarImgSrc?: string;
|
|
@@ -97,4 +98,31 @@ export default class AvatarButton extends LightningElement {
|
|
|
97
98
|
// private refreshAccessToken(refreshToken);
|
|
98
99
|
|
|
99
100
|
// private handleAuthFailure() {}
|
|
101
|
+
private async handleLogout() {
|
|
102
|
+
// TODO: Check for refresh token and invalidate.
|
|
103
|
+
if (!this._tbidAccessToken) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
Cookie.remove("TBID");
|
|
108
|
+
Cookie.remove("TBID_REFRESH");
|
|
109
|
+
|
|
110
|
+
const formData = new FormData();
|
|
111
|
+
formData.append("token", this._tbidAccessToken);
|
|
112
|
+
|
|
113
|
+
this.isLoading = true;
|
|
114
|
+
|
|
115
|
+
// TODO/QUESTION: should this hit a different or additional URL?
|
|
116
|
+
await fetch(`${TBID_REVOKE_URL}`, {
|
|
117
|
+
method: "POST",
|
|
118
|
+
headers: {
|
|
119
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
120
|
+
},
|
|
121
|
+
body: formData
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
this._tbidAccessToken = undefined;
|
|
125
|
+
this._didReceiveUserInfo = false;
|
|
126
|
+
this.isLoading = false;
|
|
127
|
+
}
|
|
100
128
|
}
|