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
|
|
2
|
-
import { y as
|
|
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
|
|
5
|
-
const [o,
|
|
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
|
-
|
|
10
|
+
i(t);
|
|
11
11
|
}
|
|
12
12
|
}, []), { FinSesion: () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
27
|
+
w as useFinalizarSesion
|
|
35
28
|
};
|
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
import i from "../../utils/fingerprint/fingerprintService.js";
|
|
2
|
+
const s = async (o, n) => {
|
|
2
3
|
try {
|
|
3
|
-
const r = await fetch(`${
|
|
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
|
-
|
|
12
|
+
datosFormulario: {
|
|
13
|
+
username: o
|
|
14
|
+
}
|
|
10
15
|
}),
|
|
11
16
|
credentials: "include"
|
|
12
|
-
}),
|
|
13
|
-
if (!
|
|
14
|
-
throw console.log(
|
|
15
|
-
return
|
|
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
|
-
|
|
26
|
+
s as FinSesionService
|
|
22
27
|
};
|