@gandalan/weblibs 0.0.29 → 0.0.34

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.
Files changed (2) hide show
  1. package/api/IDAS.js +13 -11
  2. package/package.json +1 -1
package/api/IDAS.js CHANGED
@@ -4,18 +4,11 @@ let appToken = localStorage.getItem('IDAS_AppToken') || '66B70E0B-F7C4-4829-B12A
4
4
  let authToken = localStorage.getItem('IDAS_AuthToken');
5
5
  let apiBaseUrl = localStorage.getItem('IDAS_ApiBaseUrl') || 'https://api.dev.idas-cloudservices.net/api/';
6
6
 
7
- const url = new URL(apiBaseUrl);
8
- url.pathname = '/SSO';
9
- url.search = `?a=${appToken}&r=%target%%3Ft=%token%%26m=%mandant%`;
10
- let ssoAuthUrl = url.toString();
11
-
12
7
  let restClient = new RESTClient(apiBaseUrl, authToken);
13
8
  restClient.onError = (error, message) => {
14
9
  if (message.indexOf('401') || message.indexOf('403')) {
15
- //console.log(message+" would remove Token");
16
10
  localStorage.removeItem('IDAS_AuthToken');
17
- let ssoURL = ssoAuthUrl.replace('%target%', encodeURIComponent(window.location.href));
18
- window.location = ssoURL;
11
+ new IDAS().authenticateWithSSO(true);
19
12
  }
20
13
  }
21
14
 
@@ -31,9 +24,18 @@ export class IDAS {
31
24
  return data;
32
25
  }
33
26
 
34
- async authenticateWithSSO() {
35
- if (!authToken) {
36
- let ssoURL = ssoAuthUrl.replace('%target%', encodeURIComponent(window.location.href));
27
+ async authenticateWithSSO(forceRenew = false) {
28
+ if (!authToken)
29
+ {
30
+ const url = new URL(apiBaseUrl);
31
+ url.pathname = "/SSO";
32
+ url.search = "?a=" + appToken;
33
+ if (forceRenew)
34
+ url.search = url.search + "&forceRenew=true";
35
+ url.search = url.search + "&r=%target%%3Ft=%token%%26m=%mandant%";
36
+ let ssoAuthUrl = url.toString();
37
+
38
+ var ssoURL = ssoAuthUrl.replace("%target%", encodeURIComponent(window.location.href));
37
39
  window.location = ssoURL;
38
40
  }
39
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gandalan/weblibs",
3
- "version": "0.0.29",
3
+ "version": "0.0.34",
4
4
  "description": "WebLibs for Gandalan JS/TS/Svelte projects",
5
5
  "author": "Philipp Reif",
6
6
  "license": "ISC",