authera 1.2.1 → 1.2.3

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 +12 -2
  2. package/package.json +1 -1
package/dist/web/login.js CHANGED
@@ -9,8 +9,10 @@ export default function LoginForm() {
9
9
  const [steps, stepsHnadler] = useState();
10
10
  const [activeStep, activeStepHandler] = useState();
11
11
  const [loading, loadingHandler] = useState(true);
12
+ const [userID, userIDHandler] = useState("");
13
+ const [stepPayload, stepPayloadHandler] = useState({});
12
14
  const { handleSubmit, control } = useForm();
13
- const { go_after_login_url, backendUrl } = useAuth();
15
+ const { go_after_login_url, backendUrl, setUserData } = useAuth();
14
16
  const request = axios.create({
15
17
  baseURL: backendUrl,
16
18
  });
@@ -29,7 +31,12 @@ export default function LoginForm() {
29
31
  fetchSteps();
30
32
  }, []);
31
33
  const onSubmit = async (data) => {
32
- const response = await request.post("validate/" + activeStep.name, data);
34
+ // valudate step and send data to server
35
+ const response = await request.post("validate/" + activeStep.name, {
36
+ options: data,
37
+ payload: stepPayload,
38
+ user_id: userID,
39
+ });
33
40
  // if response say go next step
34
41
  if (response.status === 202) {
35
42
  const nextIndex = (steps?.findIndex((d) => d.name === activeStep?.name) || 0) + 1;
@@ -38,11 +45,14 @@ export default function LoginForm() {
38
45
  // if response say authenticate is finished
39
46
  else if (response.status === 200) {
40
47
  window.location.href = go_after_login_url;
48
+ setUserData(response.data);
41
49
  }
42
50
  // if response say have a wrong in this request
43
51
  else if (response.status === 400) {
44
52
  activeStepHandler(steps?.[0]);
45
53
  }
54
+ userIDHandler(response.data.user_id);
55
+ stepPayloadHandler(response.data.payload);
46
56
  };
47
57
  // loading check
48
58
  if (loading)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authera",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "this project is a simple auth hook for react",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",