react-ecosistema-unp 1.3.0-pre-release.7 → 1.3.0-pre-release.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.
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
2
|
import { useState as p, useEffect as h } from "react";
|
|
3
|
-
import { useNavigate as
|
|
4
|
-
import { urlAuthDev as
|
|
5
|
-
import { j } from "../../index-CuHybtft.js";
|
|
6
|
-
const D = ({ server:
|
|
7
|
-
const [l, s] = p(!1), t =
|
|
8
|
-
let
|
|
9
|
-
return
|
|
3
|
+
import { useNavigate as k, useLocation as T, Outlet as v } from "react-router-dom";
|
|
4
|
+
import { urlAuthDev as A, urlAuthTest as U, urlAuthProd as g, urlAuthLocal as j } from "../Url.js";
|
|
5
|
+
import { j as y } from "../../index-CuHybtft.js";
|
|
6
|
+
const D = ({ server: o }) => {
|
|
7
|
+
const [l, s] = p(!1), t = k(), c = T();
|
|
8
|
+
let e;
|
|
9
|
+
return o === "dev" ? e = A : o === "test" ? e = U : o === "prod" ? e = g : e = j, h(() => {
|
|
10
10
|
(async () => {
|
|
11
11
|
try {
|
|
12
12
|
if ((await fetch(
|
|
13
|
-
`${
|
|
13
|
+
`${e}/auth/validate/`,
|
|
14
14
|
{
|
|
15
15
|
method: "POST",
|
|
16
16
|
headers: {
|
|
@@ -21,20 +21,20 @@ const D = ({ server: e }) => {
|
|
|
21
21
|
)).ok) {
|
|
22
22
|
const i = sessionStorage.getItem("user_token");
|
|
23
23
|
if (i) {
|
|
24
|
-
const
|
|
25
|
-
(
|
|
24
|
+
const u = y(i).datos_basicos.rutas, a = c.pathname, d = u.map(
|
|
25
|
+
(r) => r.startsWith("/") ? r : `/${r}`
|
|
26
26
|
), f = a.startsWith("/") ? a : `/${a}`;
|
|
27
|
-
|
|
27
|
+
d.includes(f) ? s(!0) : (s(!1), t("/"));
|
|
28
28
|
} else
|
|
29
|
-
s(!1), t("/")
|
|
29
|
+
s(!1), t("/");
|
|
30
30
|
} else
|
|
31
|
-
t("/")
|
|
32
|
-
} catch (
|
|
33
|
-
console.error("Validation error:",
|
|
31
|
+
t("/");
|
|
32
|
+
} catch (n) {
|
|
33
|
+
console.error("Validation error:", n), t("/");
|
|
34
34
|
} finally {
|
|
35
35
|
}
|
|
36
36
|
})();
|
|
37
|
-
}, [t]), l ? /* @__PURE__ */ m(
|
|
37
|
+
}, [t]), l ? /* @__PURE__ */ m(v, {}) : null;
|
|
38
38
|
};
|
|
39
39
|
export {
|
|
40
40
|
D as ProtectedRoute
|
package/package.json
CHANGED