@pronto-tools-and-more/network-process 3.17.0 → 4.0.1
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/package.json +1 -1
- package/src/parts/Login/Login.js +14 -14
package/package.json
CHANGED
package/src/parts/Login/Login.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { VError } from "@lvce-editor/verror";
|
|
2
2
|
import ky from "ky";
|
|
3
3
|
import * as Assert from "../Assert/Assert.js";
|
|
4
|
-
import * as GetXr from "../GetXr/GetXr.js";
|
|
5
4
|
|
|
6
|
-
const
|
|
5
|
+
const getBodyFormData = (userEmail, userPassword) => {
|
|
7
6
|
Assert.string(userEmail);
|
|
8
7
|
Assert.string(userPassword);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const formData = new URLSearchParams();
|
|
9
|
+
formData.set("client_id", "experience-builder");
|
|
10
|
+
formData.set("grant_type", "password");
|
|
11
|
+
formData.set("scope", "openid");
|
|
12
|
+
formData.set("username", userEmail);
|
|
13
|
+
formData.set("password", userPassword);
|
|
14
|
+
return formData;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
const getHeaders = () => {
|
|
17
|
-
const xr = GetXr.getXr();
|
|
18
18
|
return {
|
|
19
|
-
|
|
20
|
-
"content-type": "application/json",
|
|
21
|
-
xr,
|
|
19
|
+
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
22
20
|
};
|
|
23
21
|
};
|
|
24
22
|
|
|
@@ -30,14 +28,16 @@ const getHeaders = () => {
|
|
|
30
28
|
export const login = async ({ loginUrl, userEmail, userPassword }) => {
|
|
31
29
|
try {
|
|
32
30
|
Assert.string(loginUrl);
|
|
33
|
-
const body =
|
|
31
|
+
const body = getBodyFormData(userEmail, userPassword);
|
|
34
32
|
const headers = getHeaders();
|
|
35
33
|
const response = await ky(loginUrl, {
|
|
36
|
-
|
|
34
|
+
body,
|
|
37
35
|
method: "post",
|
|
38
36
|
headers,
|
|
39
37
|
});
|
|
40
|
-
|
|
38
|
+
const result = await response.json();
|
|
39
|
+
console.log({ result });
|
|
40
|
+
return result;
|
|
41
41
|
} catch (error) {
|
|
42
42
|
// @ts-ignore
|
|
43
43
|
if (error && error.name === "HTTPError") {
|