@gandalan/weblibs 0.0.2 → 0.0.6

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 +22 -18
  2. package/package.json +1 -1
package/api/IDAS.js CHANGED
@@ -1,41 +1,45 @@
1
1
  import { get, writable } from "svelte/store";
2
2
  import { RESTClient } from "./RESTClient";
3
3
 
4
- export const APP_TOKEN = "66B70E0B-F7C4-4829-B12A-18AD309E3970";
5
- export const AuthToken = writable(localStorage.getItem("AuthToken"));
6
- export const MandantGuid = writable(localStorage.getItem("MandantGuid"));
7
- export const ApiBaseUrl = writable(localStorage.getItem("ApiBaseUrl") || "https://api.dev.idas-cloudservices.net/api");
8
- export const SiteBaseUrl = writable(window.location.protocol + "//" + window.location.host);
9
- export const SSOAuthUrl = writable(get(ApiBaseUrl).replace("/api", "") + "/SSO?a=" + APP_TOKEN + "&r=%target%?t=%token%%26m=%mandant%");
4
+ let appToken = localStorage.getItem("IDAS_AppToken") || "66B70E0B-F7C4-4829-B12A-18AD309E3970";
5
+ let authToken = localStorage.getItem("IDAS_AuthToken");
6
+ let mandantGuid = localStorage.getItem("IDAS_MandantGuid");
7
+ let apiBaseUrl = localStorage.getItem("IDAS_ApiBaseUrl") || "https://api.dev.idas-cloudservices.net/api";
8
+ let siteBaseUrl = localStorage.get("SiteBaseUrl") || window.location.protocol + "//" + window.location.host;
9
+ let ssoAuthUrl = apiBaseUrl.replace("/api", "") + "/SSO?a=" + appToken + "&r=%target%?t=%token%%26m=%mandant%";
10
+ let restClient = new RESTClient(apiBaseUrl, authToken);
10
11
 
11
12
  export class IDAS
12
13
  {
13
- authToken = {};
14
- api = new RESTClient(get(ApiBaseUrl), get(AuthToken));
15
-
16
14
  async authenticate(authDTO) {
17
- var { data } = await this.api.post("/Login/Authenticate", authDTO);
18
- this.authToken = data;
15
+ authDTO.AppToken = appToken;
16
+ var { data } = await restClient.post("/Login/Authenticate", authDTO);
17
+ if (data?.Token)
18
+ {
19
+ authToken = data.Token;
20
+ restClient = new RESTClient(apiBaseUrl, authToken);
21
+ }
19
22
  return data;
20
23
  }
21
24
 
22
25
  async authenticateWithSSO() {
23
- var ssoURL = get(SSOAuthUrl).replace("%target%", get(SiteBaseUrl)).replace("%mandant%", get(MandantGuid));
26
+ var ssoURL = get(ssoAuthUrl).replace("%target%", get(siteBaseUrl)).replace("%mandant%", get(mandantGuid));
24
27
  window.location = ssoURL;
25
28
  }
26
29
 
27
30
  mandanten = {
28
- async getAll() { return await this.api.get("/Mandanten"); },
29
- async save(m) { await this.api.put("/Mandanten", m); }
31
+ async getAll() { return await restClient.get("/Mandanten"); },
32
+ async save(m) { await restClient.put("/Mandanten", m); }
30
33
  };
31
34
 
32
35
  benutzer = {
33
- async getAll() { return await this.api.get("/Benutzer"); },
34
- async save(m) { await this.api.put("/Benutzer", m); }
36
+ async getAll() { return await restClient.get("/BenutzerListe"); },
37
+ async get(guid) { return await restClient.get("/Benutzer/" + guid); },
38
+ async save(m) { await restClient.put("/Benutzer", m); }
35
39
  };
36
40
 
37
41
  rollen = {
38
- async getAll() { return await this.api.get("/Rollen"); },
39
- async save(m) { await this.api.put("/Rollen", m); }
42
+ async getAll() { return await restClient.get("/Rollen"); },
43
+ async save(m) { await restClient.put("/Rollen", m); }
40
44
  };
41
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gandalan/weblibs",
3
- "version": "0.0.2",
3
+ "version": "0.0.6",
4
4
  "description": "WebLibs for Gandalan JS/TS/Svelte projects",
5
5
  "author": "Philipp Reif",
6
6
  "license": "ISC",