react-ecosistema-unp 1.9.0 → 1.9.1-pre.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.
@@ -1,35 +1,28 @@
1
- import { FinSesionService as i } from "../services/FinSesionService.js";
2
- import { y as a } from "../../index-BUe3EJDH.js";
1
+ import { FinSesionService as r } from "../services/FinSesionService.js";
2
+ import { y as n } from "../../index-BUe3EJDH.js";
3
3
  import { useState as c, useEffect as l } from "react";
4
- const p = () => {
5
- const [o, r] = c(null), n = `${window.location.protocol}//${window.location.host}/`;
4
+ const w = () => {
5
+ const [o, i] = c(null), s = `${window.location.protocol}//${window.location.host}/`;
6
6
  return l(() => {
7
7
  const e = localStorage.getItem("auth_state");
8
8
  if (e) {
9
9
  const t = JSON.parse(e);
10
- r(t);
10
+ i(t);
11
11
  }
12
12
  }, []), { FinSesion: () => {
13
- a.promise(
14
- new Promise(async (e, t) => {
15
- try {
16
- await i((o == null ? void 0 : o.user.username) || "", n), e(!0);
17
- } catch (s) {
18
- t(s);
19
- } finally {
20
- sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), setTimeout(() => {
21
- window.location.href = n;
22
- }, 1e3);
23
- }
24
- }),
25
- {
26
- pending: "Finalizando sesión...",
27
- success: "Sesión finalizada con éxito",
28
- error: "Error al finalizar la sesión"
13
+ n.info("Finalizando sesión..."), new Promise(async (e, t) => {
14
+ try {
15
+ await r((o == null ? void 0 : o.user.username) || "", s), n.success("Sesión finalizada con éxito"), e(!0);
16
+ } catch (a) {
17
+ n.warning("Sesión finalizada localmente"), t(a);
18
+ } finally {
19
+ sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), setTimeout(() => {
20
+ window.location.href = s;
21
+ }, 1e3);
29
22
  }
30
- );
23
+ });
31
24
  } };
32
25
  };
33
26
  export {
34
- p as useFinalizarSesion
27
+ w as useFinalizarSesion
35
28
  };
@@ -1,22 +1,27 @@
1
- const n = async (e, t) => {
1
+ import i from "../../utils/fingerprint/fingerprintService.js";
2
+ const s = async (o, n) => {
2
3
  try {
3
- const r = await fetch(`${t}api-auth/auth/logout/`, {
4
+ const r = await i.getFingerprint(), t = await fetch(`${n}api-auth/auth/logout/`, {
4
5
  method: "POST",
5
6
  headers: {
6
- "Content-Type": "application/json"
7
+ "Content-Type": "application/json",
8
+ Authorization: `Bearer ${localStorage.getItem("access_token")}`,
9
+ "X-Fingerprint": r
7
10
  },
8
11
  body: JSON.stringify({
9
- username: e
12
+ datosFormulario: {
13
+ username: o
14
+ }
10
15
  }),
11
16
  credentials: "include"
12
- }), o = await r.json();
13
- if (!r.ok)
14
- throw console.log(o.error), new Error(o.error);
15
- return o;
17
+ }), e = await t.json();
18
+ if (!t.ok)
19
+ throw console.log(e.error), new Error(e.error);
20
+ return e;
16
21
  } catch (r) {
17
22
  throw new Error(r.message);
18
23
  }
19
24
  };
20
25
  export {
21
- n as FinSesionService
26
+ s as FinSesionService
22
27
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-ecosistema-unp",
3
3
  "author": "Ecosistema de Información - Unidad Nacional de Protección",
4
4
  "private": false,
5
- "version": "1.9.0",
5
+ "version": "1.9.1-pre.1",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {