ublo-lib 1.39.9 → 1.39.11
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.
- package/es/common/components/cart-dialog/cart-dialog-inner.module.css +2 -1
- package/es/esf/components/espace-prive/services/middleware.d.ts +3 -0
- package/es/esf/components/espace-prive/services/middleware.d.ts.map +1 -0
- package/es/esf/components/espace-prive/services/middleware.js +50 -0
- package/es/esf/components/espace-prive/tools.module.css +1 -1
- package/es/esf/components/espace-prive/tunnel.js +1 -1
- package/package.json +1 -1
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
|
|
97
97
|
.wrapper {
|
|
98
98
|
display: flex;
|
|
99
|
+
align-items: center;
|
|
99
100
|
gap: 10px;
|
|
100
101
|
}
|
|
101
102
|
|
|
@@ -128,7 +129,7 @@
|
|
|
128
129
|
|
|
129
130
|
.contentLabel {
|
|
130
131
|
max-width: calc(100% - 80px);
|
|
131
|
-
padding: 6px;
|
|
132
|
+
padding: 8px 6px;
|
|
132
133
|
color: var(--ds-grey-000, #fff);
|
|
133
134
|
line-height: 1;
|
|
134
135
|
font-size: 14px;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../../../src/esf/components/espace-prive/services/middleware.js"],"names":[],"mappings":"AAEO,kGAwDN;6BA1D4B,aAAa"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
export const middleware = (site, api) => async (request) => {
|
|
3
|
+
const url = request.nextUrl;
|
|
4
|
+
const { pathname } = url;
|
|
5
|
+
const clientID = url.searchParams.get("id") || request.cookies.get("id")?.value;
|
|
6
|
+
const email = url.searchParams.get("email");
|
|
7
|
+
const partnerID = getPartnerID(pathname);
|
|
8
|
+
const connexion = `/espace-prive/${partnerID}/connexion/`;
|
|
9
|
+
const isConnectedToUBLO = request.cookies.get("ublo-editing")?.value === "true";
|
|
10
|
+
if (isConnectedToUBLO) {
|
|
11
|
+
return NextResponse.next();
|
|
12
|
+
}
|
|
13
|
+
if (pathname.startsWith("/espace-prive") &&
|
|
14
|
+
!pathname.endsWith("connexion/")) {
|
|
15
|
+
try {
|
|
16
|
+
const password = request.cookies.get("password")?.value || "no-password";
|
|
17
|
+
const response = await fetch(`${api}/check-auth?site=${site}&password=${password}&partnerID=${partnerID}&id=${clientID}${email ? `&email=${email}` : ""}`);
|
|
18
|
+
const { isLoggedIn, redirect } = await response.json();
|
|
19
|
+
const redirection = redirect || response.status === 401 ? connexion : "/not-found";
|
|
20
|
+
if (isLoggedIn) {
|
|
21
|
+
if (url.searchParams.get("id")) {
|
|
22
|
+
const url = request.nextUrl.clone();
|
|
23
|
+
url.searchParams.delete("id");
|
|
24
|
+
const response = NextResponse.redirect(url);
|
|
25
|
+
response.cookies.set("id", clientID);
|
|
26
|
+
return response;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
NextResponse.next();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return NextResponse.redirect(new URL(redirection, request.url));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error(error);
|
|
38
|
+
const notFoundUrl = "/not-found";
|
|
39
|
+
return NextResponse.redirect(new URL(notFoundUrl, request.url));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function getPartnerID(path) {
|
|
44
|
+
const regex = /^\/espace-prive\/([^/]+)\/[^/]*\/?$/;
|
|
45
|
+
const match = path.match(regex);
|
|
46
|
+
if (match) {
|
|
47
|
+
return match[1];
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
@@ -11,7 +11,7 @@ export default function Tunnel() {
|
|
|
11
11
|
const { resort } = config;
|
|
12
12
|
const { intermediary, error, partnerID } = useContext();
|
|
13
13
|
const renderLoader = !intermediary && !error;
|
|
14
|
-
const renderError = error && !intermediary;
|
|
14
|
+
const renderError = error && !intermediary && !cmsMode;
|
|
15
15
|
return (_jsxs("div", { children: [renderLoader && _jsx(Loader, {}), renderError && (_jsx("div", { style: { textAlign: "center", color: "var(--ds-red-300, #f26464)" }, children: _jsx(Message, { id: "intermediary-error" }) })), !renderLoader && !renderError && (_jsx(MseM.Esf, { options: {
|
|
16
16
|
lang,
|
|
17
17
|
channel: "ESF",
|