authera 1.2.8-test-2 → 1.2.8

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/dist/web/login.js +23 -26
  2. package/package.json +1 -1
package/dist/web/login.js CHANGED
@@ -19,7 +19,7 @@ export default function LoginForm({ on_after_login, on_after_step, }) {
19
19
  // fetch data from steps
20
20
  useEffect(() => {
21
21
  async function fetchSteps() {
22
- const response = await request.get("options/");
22
+ const response = await request.get("options");
23
23
  const data = Object.entries(response.data).map(([opt, schema]) => ({
24
24
  name: opt,
25
25
  structure: convertFromSchema(schema),
@@ -30,36 +30,33 @@ export default function LoginForm({ on_after_login, on_after_step, }) {
30
30
  }
31
31
  fetchSteps();
32
32
  }, []);
33
- const onSubmit = (data) => {
33
+ const onSubmit = async (data) => {
34
34
  // valudate step and send data to server
35
- request
36
- .post("validate/" + activeStep.name, {
35
+ const response = await request.post("validate/" + activeStep.name, {
37
36
  options: data,
38
37
  payload: stepPayload,
39
38
  user_id: userID,
40
- })
41
- .then((response) => {
42
- // if response say go next step
43
- if (response.status === 202) {
44
- const nextIndex = (steps?.findIndex((d) => d.name === activeStep?.name) || 0) + 1;
45
- activeStepHandler(steps?.[nextIndex]);
46
- if (on_after_step)
47
- on_after_step(steps?.[nextIndex]?.name || "");
48
- }
49
- // if response say authenticate is finished
50
- else if (response.status === 200) {
51
- setUserData(response.data.user);
52
- setPermits(response.data.user.permits);
53
- if (on_after_login)
54
- on_after_login(response.data);
55
- }
56
- // if response say have a wrong in this request
57
- else if (response.status === 400) {
58
- activeStepHandler(steps?.[0]);
59
- }
60
- userIDHandler(response.data.user_id);
61
- stepPayloadHandler(response.data.payload);
62
39
  });
40
+ // if response say go next step
41
+ if (response.status === 202) {
42
+ const nextIndex = (steps?.findIndex((d) => d.name === activeStep?.name) || 0) + 1;
43
+ activeStepHandler(steps?.[nextIndex]);
44
+ if (on_after_step)
45
+ on_after_step(steps?.[nextIndex]?.name || "");
46
+ }
47
+ // if response say authenticate is finished
48
+ else if (response.status === 200) {
49
+ setUserData(response.data.user);
50
+ setPermits(response.data.user.permits);
51
+ if (on_after_login)
52
+ on_after_login(response.data);
53
+ }
54
+ // if response say have a wrong in this request
55
+ else if (response.status === 400) {
56
+ activeStepHandler(steps?.[0]);
57
+ }
58
+ userIDHandler(response.data.user_id);
59
+ stepPayloadHandler(response.data.payload);
63
60
  };
64
61
  // loading check
65
62
  if (loading)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authera",
3
- "version": "1.2.8-test-2",
3
+ "version": "1.2.8",
4
4
  "description": "this project is a simple auth hook for react",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",