zavadil-ts-common 1.2.22 → 1.2.24
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.
@@ -40,7 +40,8 @@ export class RestClientWithOAuth extends RestClient {
|
|
40
40
|
return this.setIdTokenRaw(urlToken)
|
41
41
|
.then(() => {
|
42
42
|
console.log("Redirecting to url without id token");
|
43
|
-
|
43
|
+
this.deleteIdTokenFromUrl();
|
44
|
+
//document.location =;
|
44
45
|
});
|
45
46
|
} else {
|
46
47
|
const storageToken = this.getIdTokenFromLocalStorage();
|
@@ -86,10 +87,10 @@ export class RestClientWithOAuth extends RestClient {
|
|
86
87
|
return this.defaultPrivilege;
|
87
88
|
}
|
88
89
|
|
89
|
-
deleteIdTokenFromUrl()
|
90
|
+
deleteIdTokenFromUrl() {
|
90
91
|
const up = new URLSearchParams(document.location.search);
|
91
92
|
up.delete(this.tokenName);
|
92
|
-
|
93
|
+
document.location.search = up.toString();
|
93
94
|
}
|
94
95
|
|
95
96
|
getIdTokenFromUrl(): string | null {
|
@@ -169,19 +170,13 @@ export class RestClientWithOAuth extends RestClient {
|
|
169
170
|
}
|
170
171
|
|
171
172
|
/**
|
172
|
-
* Try to obtain access token, then return
|
173
|
+
* Try to obtain access token, then return if everything is okay.
|
173
174
|
* This is basically only used when initializing and trying to determine whether we need to redirect user to login page
|
174
175
|
*/
|
175
|
-
checkAccessToken(privilege?: string): Promise<
|
176
|
+
checkAccessToken(privilege?: string): Promise<any> {
|
176
177
|
return this.getTokenManager()
|
177
178
|
.then(tm => tm.getAccessToken(StringUtil.getNonEmpty(privilege, this.defaultPrivilege)))
|
178
|
-
.
|
179
|
-
.catch(
|
180
|
-
(e) => {
|
181
|
-
console.error('Access token check failed:', e);
|
182
|
-
return false;
|
183
|
-
}
|
184
|
-
);
|
179
|
+
.catch((e) => Promise.reject(`Access token check failed: ${e}`));
|
185
180
|
}
|
186
181
|
|
187
182
|
}
|