@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.
- package/api/IDAS.js +22 -18
- 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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
18
|
-
|
|
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(
|
|
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
|
|
29
|
-
async save(m) { await
|
|
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
|
|
34
|
-
async
|
|
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
|
|
39
|
-
async save(m) { await
|
|
42
|
+
async getAll() { return await restClient.get("/Rollen"); },
|
|
43
|
+
async save(m) { await restClient.put("/Rollen", m); }
|
|
40
44
|
};
|
|
41
45
|
}
|