@gandalan/weblibs 1.1.61 → 1.1.63
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/api/fluentApi.js +5 -25
- package/api/fluentAuthBuilder.js +4 -5
- package/package.json +1 -1
package/api/fluentApi.js
CHANGED
|
@@ -290,9 +290,12 @@ export function createApi() {
|
|
|
290
290
|
globalThis.idasTokens.token = this.token;
|
|
291
291
|
// eslint-disable-next-line no-undef
|
|
292
292
|
globalThis.idasTokens.refreshToken = this.refreshToken;
|
|
293
|
+
// eslint-disable-next-line no-undef
|
|
294
|
+
globalThis.idasTokens.userInfo = jwtDecode(this.token);
|
|
293
295
|
localStorage.setItem("idas-refresh-token", this.refreshToken);
|
|
294
296
|
} catch (e) {
|
|
295
|
-
this.redirectToLogin();
|
|
297
|
+
//this.redirectToLogin();
|
|
298
|
+
console.error("not authenticated", e);
|
|
296
299
|
}
|
|
297
300
|
},
|
|
298
301
|
|
|
@@ -318,30 +321,7 @@ export function createApi() {
|
|
|
318
321
|
if (!this.authUrl) {
|
|
319
322
|
throw new Error("authUrl not set");
|
|
320
323
|
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Redirect to the login page
|
|
325
|
-
*
|
|
326
|
-
* @param {string} [authPath=""]
|
|
327
|
-
* @private
|
|
328
|
-
*/
|
|
329
|
-
redirectToLogin(authPath = "") {
|
|
330
|
-
if (!window) {
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const authEndpoint = (new URL(window.location.href).origin) + authPath;
|
|
335
|
-
let authUrlCallback = `${authEndpoint}?r=%target%&j=%jwt%&m=%mandant%`;
|
|
336
|
-
authUrlCallback = authUrlCallback.replace("%target%", encodeURIComponent(window.location.href));
|
|
337
|
-
|
|
338
|
-
const url = new URL(this.authUrl);
|
|
339
|
-
url.pathname = "/Session";
|
|
340
|
-
url.search = `?a=${this.appToken}&r=${encodeURIComponent(authUrlCallback)}`;
|
|
341
|
-
let loginUrl = url.toString();
|
|
342
|
-
|
|
343
|
-
window.location.href = loginUrl;
|
|
344
|
-
},
|
|
324
|
+
}
|
|
345
325
|
};
|
|
346
326
|
}
|
|
347
327
|
|
package/api/fluentAuthBuilder.js
CHANGED
|
@@ -166,7 +166,7 @@ export function authBuilder() {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// eslint-disable-next-line no-undef
|
|
169
|
-
globalThis.idasTokens = { token: this.token, refreshToken: this.refreshToken, appToken: this.appToken };
|
|
169
|
+
globalThis.idasTokens = { token: this.token, refreshToken: this.refreshToken, appToken: this.appToken, userInfo: jwtDecode(this.token) };
|
|
170
170
|
},
|
|
171
171
|
|
|
172
172
|
/**
|
|
@@ -179,14 +179,13 @@ export function authBuilder() {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
const redirectAfterAuth = new URL(window.location.href).origin;
|
|
182
|
-
let redirectUrl = `${redirectAfterAuth}?r=%target%&j=%jwt%&m=%mandant%`;
|
|
183
|
-
redirectUrl = redirectUrl.replace("%target%", encodeURIComponent(window.location.href));
|
|
184
|
-
|
|
182
|
+
//let redirectUrl = `${redirectAfterAuth}?r=%target%&j=%jwt%&m=%mandant%`;
|
|
183
|
+
//redirectUrl = redirectUrl.replace("%target%", encodeURIComponent(window.location.href));
|
|
184
|
+
let redirectUrl = `${redirectAfterAuth}?t=%token%`;
|
|
185
185
|
const url = new URL(this.authUrl);
|
|
186
186
|
url.pathname = "/Session";
|
|
187
187
|
url.search = `?a=${this.appToken}&r=${encodeURIComponent(redirectUrl)}`;
|
|
188
188
|
let loginUrl = url.toString();
|
|
189
|
-
|
|
190
189
|
window.location.href = loginUrl;
|
|
191
190
|
}
|
|
192
191
|
};
|