zavadil-ts-common 1.1.51 → 1.1.53
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/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/oauth/RestClientWithOAuth.ts +9 -3
@@ -2,7 +2,7 @@ import {OAuthTokenManager} from "./OAuthTokenManager";
|
|
2
2
|
import {RestClient, RestClientHeaders} from "../client";
|
3
3
|
import {IdTokenPayload} from "./OAuthRestClient";
|
4
4
|
import {LazyAsync} from "../cache";
|
5
|
-
import {StringUtil} from "../util";
|
5
|
+
import {DateUtil, StringUtil} from "../util";
|
6
6
|
|
7
7
|
export type ServerOAuthInfoPayload = {
|
8
8
|
debugMode?: boolean;
|
@@ -57,7 +57,12 @@ export class RestClientWithOAuth extends RestClient {
|
|
57
57
|
getIdTokenFromLocalStorage(): IdTokenPayload | null {
|
58
58
|
const raw = localStorage.getItem('id-token');
|
59
59
|
if (!raw) return null;
|
60
|
-
|
60
|
+
const obj = JSON.parse(raw);
|
61
|
+
return {
|
62
|
+
idToken: obj.idToken,
|
63
|
+
issuedAt: DateUtil.parseDate(obj.issuedAt) || new Date(),
|
64
|
+
expires: DateUtil.parseDate(obj.expires)
|
65
|
+
}
|
61
66
|
}
|
62
67
|
|
63
68
|
saveIdTokenToLocalStorage(token: IdTokenPayload | null) {
|
@@ -139,7 +144,8 @@ export class RestClientWithOAuth extends RestClient {
|
|
139
144
|
.catch(
|
140
145
|
() => this.getServerInfo().then(
|
141
146
|
(si) => {
|
142
|
-
|
147
|
+
const documentlocation = `${si.oauthServerUrl}/login?app_name=${si.targetAudience}&redirect_url=${document.location}`;
|
148
|
+
console.log('redirect', documentlocation);
|
143
149
|
return Promise.resolve(false);
|
144
150
|
}
|
145
151
|
)
|