@ciscode/ui-authentication-kit 1.0.4 → 1.0.6
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/dist/components/RequirePermissions.js +1 -1
- package/dist/components/RequirePermissions.js.map +1 -1
- package/dist/index.mjs +492 -448
- package/dist/index.umd.js +7 -37
- package/dist/pages/auth/ForgotPasswordPage.d.ts +3 -0
- package/dist/pages/auth/ForgotPasswordPage.d.ts.map +1 -0
- package/dist/pages/auth/ForgotPasswordPage.js +70 -0
- package/dist/pages/auth/ForgotPasswordPage.js.map +1 -0
- package/dist/pages/auth/ResetPasswordPage.d.ts +3 -0
- package/dist/pages/auth/ResetPasswordPage.d.ts.map +1 -0
- package/dist/pages/auth/ResetPasswordPage.js +93 -0
- package/dist/pages/auth/ResetPasswordPage.js.map +1 -0
- package/dist/pages/auth/SignInPage.d.ts.map +1 -1
- package/dist/pages/auth/SignInPage.js +3 -2
- package/dist/pages/auth/SignInPage.js.map +1 -1
- package/dist/pages/auth/SignUpPage.d.ts.map +1 -1
- package/dist/pages/auth/SignUpPage.js +19 -8
- package/dist/pages/auth/SignUpPage.js.map +1 -1
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/dist/providers/AuthProvider.js +6 -2
- package/dist/providers/AuthProvider.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import e, { createContext as
|
|
3
|
-
import
|
|
4
|
-
import { jwtDecode as
|
|
5
|
-
import
|
|
6
|
-
import { useT as
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import * as R from "react";
|
|
2
|
+
import e, { createContext as we, useContext as Ee, useEffect as W, useState as i, useMemo as J } from "react";
|
|
3
|
+
import oe from "axios";
|
|
4
|
+
import { jwtDecode as ye } from "jwt-decode";
|
|
5
|
+
import Ne from "react-dom";
|
|
6
|
+
import { useT as Z } from "@ciscode/ui-translate-core";
|
|
7
|
+
import { AlertTriangle as ve, X as ke } from "lucide-react";
|
|
8
|
+
import { useNavigate as q, useLocation as ee, Link as Me, Routes as Ie, Route as B, Navigate as K } from "react-router-dom";
|
|
9
|
+
const de = e.createContext(null);
|
|
10
|
+
function te() {
|
|
11
|
+
const t = e.useContext(de);
|
|
11
12
|
if (!t)
|
|
12
13
|
throw new Error("useAuthConfig must be used within an AuthConfigProvider");
|
|
13
14
|
return t;
|
|
14
15
|
}
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
const t =
|
|
16
|
+
const ue = we(null);
|
|
17
|
+
function T() {
|
|
18
|
+
const t = Ee(ue);
|
|
18
19
|
if (!t)
|
|
19
20
|
throw new Error("useAuthState must be inside <AuthProvider>");
|
|
20
21
|
return t;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
const a =
|
|
23
|
+
function ne(t) {
|
|
24
|
+
const a = ye(t);
|
|
24
25
|
return {
|
|
25
26
|
id: a.sub,
|
|
26
27
|
email: a.email ?? "",
|
|
@@ -30,54 +31,54 @@ function J(t) {
|
|
|
30
31
|
tenantId: a.tenantId ?? ""
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
|
-
let
|
|
34
|
-
function
|
|
35
|
-
|
|
34
|
+
let ce = !1;
|
|
35
|
+
function Le() {
|
|
36
|
+
ce = !1;
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
+
function Pe(t, a) {
|
|
38
39
|
t.defaults.withCredentials = !0;
|
|
39
|
-
const
|
|
40
|
-
t.interceptors.request.use((
|
|
40
|
+
const r = `${a.baseUrl}${a.refreshEndpoint ?? "/auth/refresh-token"}`;
|
|
41
|
+
t.interceptors.request.use((s) => {
|
|
41
42
|
const o = a.getAccessToken();
|
|
42
|
-
return o && (
|
|
43
|
+
return o && (s.headers.Authorization = `Bearer ${o}`), s;
|
|
43
44
|
});
|
|
44
|
-
let
|
|
45
|
+
let l = !1, n = [];
|
|
45
46
|
return t.interceptors.response.use(
|
|
46
|
-
(
|
|
47
|
-
async (
|
|
48
|
-
var
|
|
49
|
-
const o =
|
|
50
|
-
if (((
|
|
51
|
-
return Promise.reject(
|
|
52
|
-
if (o._retry = !0, !
|
|
53
|
-
|
|
47
|
+
(s) => s,
|
|
48
|
+
async (s) => {
|
|
49
|
+
var d;
|
|
50
|
+
const o = s.config;
|
|
51
|
+
if (((d = s.response) == null ? void 0 : d.status) !== 401 || !o || o._retry)
|
|
52
|
+
return Promise.reject(s);
|
|
53
|
+
if (o._retry = !0, !l) {
|
|
54
|
+
l = !0;
|
|
54
55
|
try {
|
|
55
|
-
const { data:
|
|
56
|
-
return a.setAccessToken(
|
|
57
|
-
} catch (
|
|
58
|
-
return !!a.getAccessToken() && !
|
|
56
|
+
const { data: c } = await oe.post(r, {}, { withCredentials: !0 });
|
|
57
|
+
return a.setAccessToken(c.accessToken), n.forEach((u) => u(c.accessToken)), n = [], t.request(o);
|
|
58
|
+
} catch (c) {
|
|
59
|
+
return !!a.getAccessToken() && !ce && (ce = !0, a.logout()), n.forEach((b) => b(null)), n = [], Promise.reject(c);
|
|
59
60
|
} finally {
|
|
60
|
-
|
|
61
|
+
l = !1;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
return new Promise((
|
|
64
|
-
|
|
65
|
-
if (!
|
|
66
|
-
return
|
|
67
|
-
(o.headers ?? (o.headers = {})).Authorization = `Bearer ${
|
|
64
|
+
return new Promise((c, u) => {
|
|
65
|
+
n.push((b) => {
|
|
66
|
+
if (!b)
|
|
67
|
+
return u(s);
|
|
68
|
+
(o.headers ?? (o.headers = {})).Authorization = `Bearer ${b}`, c(t.request(o));
|
|
68
69
|
});
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
), t;
|
|
72
73
|
}
|
|
73
|
-
const
|
|
74
|
-
const a =
|
|
75
|
-
return
|
|
76
|
-
const { body:
|
|
77
|
-
return
|
|
78
|
-
|
|
74
|
+
const Ce = ({ onConfirm: t }) => {
|
|
75
|
+
const a = Z("authLib");
|
|
76
|
+
return W(() => {
|
|
77
|
+
const { body: r } = document, l = r.style.overflow, n = r.style.pointerEvents;
|
|
78
|
+
return r.style.overflow = "hidden", r.style.pointerEvents = "none", () => {
|
|
79
|
+
r.style.overflow = l, r.style.pointerEvents = n;
|
|
79
80
|
};
|
|
80
|
-
}, []),
|
|
81
|
+
}, []), Ne.createPortal(
|
|
81
82
|
/* @__PURE__ */ e.createElement("div", { className: "fixed inset-0 z-[9999] flex items-center justify-center bg-black/40 backdrop-blur-sm" }, /* @__PURE__ */ e.createElement("div", { className: "pointer-events-auto w-full max-w-sm rounded-xl bg-white p-6 shadow-xl" }, /* @__PURE__ */ e.createElement("h2", { className: "mb-4 text-xl font-semibold text-gray-800 ltr:text-left rtl:text-center" }, a("sessionExpired.title")), /* @__PURE__ */ e.createElement("p", { className: "mb-8 text-sm text-gray-600 ltr:text-left rtl:text-center" }, a("sessionExpired.message")), /* @__PURE__ */ e.createElement("div", { className: "flex justify-end" }, /* @__PURE__ */ e.createElement(
|
|
82
83
|
"button",
|
|
83
84
|
{
|
|
@@ -92,38 +93,38 @@ const Me = ({ onConfirm: t }) => {
|
|
|
92
93
|
)))),
|
|
93
94
|
document.body
|
|
94
95
|
);
|
|
95
|
-
},
|
|
96
|
+
}, P = ({
|
|
96
97
|
label: t,
|
|
97
98
|
type: a = "text",
|
|
98
|
-
placeholder:
|
|
99
|
-
color:
|
|
100
|
-
value:
|
|
101
|
-
onChange:
|
|
99
|
+
placeholder: r,
|
|
100
|
+
color: l = "",
|
|
101
|
+
value: n,
|
|
102
|
+
onChange: s
|
|
102
103
|
}) => {
|
|
103
|
-
const o =
|
|
104
|
-
return /* @__PURE__ */
|
|
104
|
+
const o = R.useId();
|
|
105
|
+
return /* @__PURE__ */ R.createElement("div", { className: "mt-8 flex flex-col" }, t && /* @__PURE__ */ R.createElement(
|
|
105
106
|
"label",
|
|
106
107
|
{
|
|
107
108
|
htmlFor: o,
|
|
108
109
|
className: "self-start text-base text-black dark:text-white block ltr:text-left rtl:text-right"
|
|
109
110
|
},
|
|
110
111
|
t
|
|
111
|
-
), /* @__PURE__ */
|
|
112
|
+
), /* @__PURE__ */ R.createElement(
|
|
112
113
|
"input",
|
|
113
114
|
{
|
|
114
115
|
id: o,
|
|
115
116
|
type: a,
|
|
116
|
-
placeholder:
|
|
117
|
-
value:
|
|
118
|
-
onChange: (
|
|
117
|
+
placeholder: r || void 0,
|
|
118
|
+
value: n,
|
|
119
|
+
onChange: (d) => s == null ? void 0 : s(d.target.value),
|
|
119
120
|
className: `
|
|
120
121
|
px-4 py-4 mt-3.5 text-sm font-light rounded-lg border border-solid w-full
|
|
121
122
|
ltr:text-left rtl:text-right
|
|
122
|
-
${
|
|
123
|
+
${l}
|
|
123
124
|
`
|
|
124
125
|
}
|
|
125
126
|
));
|
|
126
|
-
},
|
|
127
|
+
}, ge = ({ icon: t, label: a }) => /* @__PURE__ */ R.createElement("div", { className: "flex gap-5 px-8 py-3 items-center bg-indigo-50 rounded-lg max-md:px-5" }, /* @__PURE__ */ R.createElement(
|
|
127
128
|
"img",
|
|
128
129
|
{
|
|
129
130
|
loading: "lazy",
|
|
@@ -131,132 +132,31 @@ const Me = ({ onConfirm: t }) => {
|
|
|
131
132
|
alt: a || "",
|
|
132
133
|
className: "object-contain shrink-0 aspect-square w-[26px]"
|
|
133
134
|
}
|
|
134
|
-
), a && /* @__PURE__ */
|
|
135
|
-
function
|
|
136
|
-
return t ? t.startsWith(`${a}-`) ? t : t.startsWith("#") ? `${t}` :
|
|
135
|
+
), a && /* @__PURE__ */ R.createElement("div", { className: "basis-auto text-sm hidden md:block ltr:text-left rtl:text-right" }, a)), fe = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iLTMgMCAyNjIgMjYyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIj48cGF0aCBkPSJNMjU1Ljg3OCAxMzMuNDUxYzAtMTAuNzM0LS44NzEtMTguNTY3LTIuNzU2LTI2LjY5SDEzMC41NXY0OC40NDhoNzEuOTQ3Yy0xLjQ1IDEyLjA0LTkuMjgzIDMwLjE3Mi0yNi42OSA0Mi4zNTZsLS4yNDQgMS42MjIgMzguNzU1IDMwLjAyMyAyLjY4NS4yNjhjMjQuNjU5LTIyLjc3NCAzOC44NzUtNTYuMjgyIDM4Ljg3NS05Ni4wMjciIGZpbGw9IiM0Mjg1RjQiLz48cGF0aCBkPSJNMTMwLjU1IDI2MS4xYzM1LjI0OCAwIDY0LjgzOS0xMS42MDUgODYuNDUzLTMxLjYyMmwtNDEuMTk2LTMxLjkxM2MtMTEuMDI0IDcuNjg4LTI1LjgyIDEzLjA1NS00NS4yNTcgMTMuMDU1LTM0LjUyMyAwLTYzLjgyNC0yMi43NzMtNzQuMjY5LTU0LjI1bC0xLjUzMS4xMy00MC4yOTggMzEuMTg3LS41MjcgMS40NjVDMzUuMzkzIDIzMS43OTggNzkuNDkgMjYxLjEgMTMwLjU1IDI2MS4xIiBmaWxsPSIjMzRBODUzIi8+PHBhdGggZD0iTTU2LjI4MSAxNTYuMzdjLTIuNzU2LTguMTIzLTQuMzUxLTE2LjgyNy00LjM1MS0yNS44MiAwLTguOTk0IDEuNTk1LTE3LjY5NyA0LjIwNi0yNS44MmwtLjA3My0xLjczTDE1LjI2IDcxLjMxMmwtMS4zMzUuNjM1QzUuMDc3IDg5LjY0NCAwIDEwOS41MTcgMCAxMzAuNTVzNS4wNzcgNDAuOTA1IDEzLjkyNSA1OC42MDJsNDIuMzU2LTMyLjc4MiIgZmlsbD0iI0ZCQkMwNSIvPjxwYXRoIGQ9Ik0xMzAuNTUgNTAuNDc5YzI0LjUxNCAwIDQxLjA1IDEwLjU4OSA1MC40NzkgMTkuNDM4bDM2Ljg0NC0zNS45NzRDMTk1LjI0NSAxMi45MSAxNjUuNzk4IDAgMTMwLjU1IDAgNzkuNDkgMCAzNS4zOTMgMjkuMzAxIDEzLjkyNSA3MS45NDdsNDIuMjExIDMyLjc4M2MxMC41OS0zMS40NzcgMzkuODkxLTU0LjI1MSA3NC40MTQtNTQuMjUxIiBmaWxsPSIjRUI0MzM1Ii8+PC9zdmc+", he = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE2IDE2IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiPjxwYXRoIGZpbGw9IiNGMzUzMjUiIGQ9Ik0xIDFoNi41djYuNUgxVjF6Ii8+PHBhdGggZmlsbD0iIzgxQkMwNiIgZD0iTTguNSAxSDE1djYuNUg4LjVWMXoiLz48cGF0aCBmaWxsPSIjMDVBNkYwIiBkPSJNMSA4LjVoNi41VjE1SDFWOC41eiIvPjxwYXRoIGZpbGw9IiNGRkJBMDgiIGQ9Ik04LjUgOC41SDE1VjE1SDguNVY4LjV6Ii8+PC9zdmc+";
|
|
136
|
+
function X(t, a, r) {
|
|
137
|
+
return t ? t.startsWith(`${a}-`) ? t : t.startsWith("#") ? `${t}` : r : r;
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
-
const
|
|
139
|
+
function ae(t, a) {
|
|
140
|
+
const r = (a == null ? void 0 : a.bg) || "bg-sky-500", l = (a == null ? void 0 : a.text) || "text-gray-800", n = (a == null ? void 0 : a.border) || "border-gray-300", s = (a == null ? void 0 : a.fill) || "fill-current", o = (a == null ? void 0 : a.stroke) || "stroke-current";
|
|
140
141
|
return {
|
|
141
|
-
bgClass:
|
|
142
|
-
textClass:
|
|
143
|
-
borderClass:
|
|
144
|
-
fillClass:
|
|
145
|
-
strokeClass:
|
|
142
|
+
bgClass: X(t.bg ?? "", "bg", r),
|
|
143
|
+
textClass: X(t.text ?? "", "text", l),
|
|
144
|
+
borderClass: X(t.border ?? "", "border", n),
|
|
145
|
+
fillClass: X(t.fill ?? "", "fill", s),
|
|
146
|
+
strokeClass: X(t.stroke ?? "", "stroke", o)
|
|
146
147
|
};
|
|
147
148
|
}
|
|
148
|
-
|
|
149
|
-
* @license lucide-react v0.481.0 - ISC
|
|
150
|
-
*
|
|
151
|
-
* This source code is licensed under the ISC license.
|
|
152
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
153
|
-
*/
|
|
154
|
-
const Ie = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ue = (...t) => t.filter((a, l, r) => !!a && a.trim() !== "" && r.indexOf(a) === l).join(" ").trim();
|
|
155
|
-
/**
|
|
156
|
-
* @license lucide-react v0.481.0 - ISC
|
|
157
|
-
*
|
|
158
|
-
* This source code is licensed under the ISC license.
|
|
159
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
160
|
-
*/
|
|
161
|
-
var ke = {
|
|
162
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
163
|
-
width: 24,
|
|
164
|
-
height: 24,
|
|
165
|
-
viewBox: "0 0 24 24",
|
|
166
|
-
fill: "none",
|
|
167
|
-
stroke: "currentColor",
|
|
168
|
-
strokeWidth: 2,
|
|
169
|
-
strokeLinecap: "round",
|
|
170
|
-
strokeLinejoin: "round"
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* @license lucide-react v0.481.0 - ISC
|
|
174
|
-
*
|
|
175
|
-
* This source code is licensed under the ISC license.
|
|
176
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
177
|
-
*/
|
|
178
|
-
const Le = le(
|
|
179
|
-
({
|
|
180
|
-
color: t = "currentColor",
|
|
181
|
-
size: a = 24,
|
|
182
|
-
strokeWidth: l = 2,
|
|
183
|
-
absoluteStrokeWidth: r,
|
|
184
|
-
className: s = "",
|
|
185
|
-
children: n,
|
|
186
|
-
iconNode: o,
|
|
187
|
-
...c
|
|
188
|
-
}, i) => q(
|
|
189
|
-
"svg",
|
|
190
|
-
{
|
|
191
|
-
ref: i,
|
|
192
|
-
...ke,
|
|
193
|
-
width: a,
|
|
194
|
-
height: a,
|
|
195
|
-
stroke: t,
|
|
196
|
-
strokeWidth: r ? Number(l) * 24 / Number(a) : l,
|
|
197
|
-
className: ue("lucide", s),
|
|
198
|
-
...c
|
|
199
|
-
},
|
|
200
|
-
[
|
|
201
|
-
...o.map(([m, p]) => q(m, p)),
|
|
202
|
-
...Array.isArray(n) ? n : [n]
|
|
203
|
-
]
|
|
204
|
-
)
|
|
205
|
-
);
|
|
206
|
-
/**
|
|
207
|
-
* @license lucide-react v0.481.0 - ISC
|
|
208
|
-
*
|
|
209
|
-
* This source code is licensed under the ISC license.
|
|
210
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
-
*/
|
|
212
|
-
const ge = (t, a) => {
|
|
213
|
-
const l = le(
|
|
214
|
-
({ className: r, ...s }, n) => q(Le, {
|
|
215
|
-
ref: n,
|
|
216
|
-
iconNode: a,
|
|
217
|
-
className: ue(`lucide-${Ie(t)}`, r),
|
|
218
|
-
...s
|
|
219
|
-
})
|
|
220
|
-
);
|
|
221
|
-
return l.displayName = `${t}`, l;
|
|
222
|
-
};
|
|
223
|
-
/**
|
|
224
|
-
* @license lucide-react v0.481.0 - ISC
|
|
225
|
-
*
|
|
226
|
-
* This source code is licensed under the ISC license.
|
|
227
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
228
|
-
*/
|
|
229
|
-
const Ce = [
|
|
230
|
-
[
|
|
231
|
-
"path",
|
|
232
|
-
{
|
|
233
|
-
d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
|
|
234
|
-
key: "wmoenq"
|
|
235
|
-
}
|
|
236
|
-
],
|
|
237
|
-
["path", { d: "M12 9v4", key: "juzpu7" }],
|
|
238
|
-
["path", { d: "M12 17h.01", key: "p32p05" }]
|
|
239
|
-
], je = ge("TriangleAlert", Ce);
|
|
240
|
-
/**
|
|
241
|
-
* @license lucide-react v0.481.0 - ISC
|
|
242
|
-
*
|
|
243
|
-
* This source code is licensed under the ISC license.
|
|
244
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
245
|
-
*/
|
|
246
|
-
const Se = [
|
|
247
|
-
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
248
|
-
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
249
|
-
], Te = ge("X", Se), fe = ({
|
|
149
|
+
const le = ({
|
|
250
150
|
message: t,
|
|
251
151
|
dismissAfterMs: a = 4e3
|
|
252
152
|
}) => {
|
|
253
|
-
const
|
|
254
|
-
return
|
|
255
|
-
if (
|
|
256
|
-
const
|
|
257
|
-
return () => window.clearTimeout(
|
|
153
|
+
const r = Z("authLib"), [l, n] = i(!1);
|
|
154
|
+
return W(() => {
|
|
155
|
+
if (n(!!t), t && a > 0) {
|
|
156
|
+
const s = window.setTimeout(() => n(!1), a);
|
|
157
|
+
return () => window.clearTimeout(s);
|
|
258
158
|
}
|
|
259
|
-
}, [t, a]), !
|
|
159
|
+
}, [t, a]), !l || !t ? null : /* @__PURE__ */ e.createElement(
|
|
260
160
|
"div",
|
|
261
161
|
{
|
|
262
162
|
role: "alert",
|
|
@@ -266,81 +166,81 @@ const Se = [
|
|
|
266
166
|
rounded-lg border border-red-300 bg-red-50/80 p-4 pr-6 text-sm text-red-800
|
|
267
167
|
shadow-lg backdrop-blur
|
|
268
168
|
transition-all duration-300 ease-out
|
|
269
|
-
${
|
|
169
|
+
${l ? "translate-y-0 opacity-100" : "-translate-y-2 opacity-0"}
|
|
270
170
|
`
|
|
271
171
|
},
|
|
272
172
|
/* @__PURE__ */ e.createElement("span", { className: "absolute ltr:left-0 rtl:right-0 top-0 h-full w-1 bg-gradient-to-b from-red-500 to-red-400" }),
|
|
273
|
-
/* @__PURE__ */ e.createElement(
|
|
173
|
+
/* @__PURE__ */ e.createElement(ve, { className: "mt-0.5 h-5 w-5 flex-none" }),
|
|
274
174
|
/* @__PURE__ */ e.createElement("span", { className: "grow leading-5 ltr:text-left rtl:text-right" }, t),
|
|
275
175
|
/* @__PURE__ */ e.createElement(
|
|
276
176
|
"button",
|
|
277
177
|
{
|
|
278
|
-
onClick: () =>
|
|
279
|
-
"aria-label":
|
|
178
|
+
onClick: () => n(!1),
|
|
179
|
+
"aria-label": r("inlineError.dismiss"),
|
|
280
180
|
className: `
|
|
281
181
|
absolute ltr:right-2 rtl:left-2 top-2 rounded p-1 text-red-600/70
|
|
282
182
|
hover:bg-red-100 hover:text-red-700 focus:outline-none
|
|
283
183
|
focus-visible:ring focus-visible:ring-red-500/50
|
|
284
184
|
`
|
|
285
185
|
},
|
|
286
|
-
/* @__PURE__ */ e.createElement(
|
|
186
|
+
/* @__PURE__ */ e.createElement(ke, { className: "h-4 w-4" })
|
|
287
187
|
)
|
|
288
188
|
);
|
|
289
|
-
},
|
|
290
|
-
const t =
|
|
291
|
-
brandName:
|
|
292
|
-
colors:
|
|
293
|
-
logoUrl:
|
|
189
|
+
}, Se = () => {
|
|
190
|
+
const t = Z("authLib"), a = q(), r = ee(), {
|
|
191
|
+
brandName: l = t("brandName", { defaultValue: "MyBrand" }),
|
|
192
|
+
colors: n = { bg: "bg-sky-500", text: "text-white", border: "border-sky-500" },
|
|
193
|
+
logoUrl: s,
|
|
294
194
|
oauthProviders: o = [],
|
|
295
|
-
illustrationUrl:
|
|
195
|
+
illustrationUrl: d = t("community.illustrationUrl", {
|
|
296
196
|
defaultValue: "https://cdn.builder.io/api/v1/image/assets/TEMP/35ba84b8335fda2819c3a14ea3d00321a0fd0e79e571caa31108468010868ca5?placeholderIfAbsent=true&apiKey=a460e9a46e514356ac1106eada03046c"
|
|
297
197
|
}),
|
|
298
|
-
communityContent:
|
|
198
|
+
communityContent: c = {
|
|
299
199
|
title: t("community.title"),
|
|
300
200
|
description: t("community.description")
|
|
301
201
|
},
|
|
302
|
-
baseUrl:
|
|
202
|
+
baseUrl: u
|
|
303
203
|
// IMPORTANT: used for Google OAuth redirect
|
|
304
|
-
} =
|
|
305
|
-
google: { icon:
|
|
306
|
-
microsoft: { icon:
|
|
307
|
-
},
|
|
308
|
-
id:
|
|
309
|
-
icon:
|
|
310
|
-
label:
|
|
311
|
-
})), { bgClass:
|
|
312
|
-
async function
|
|
313
|
-
var
|
|
314
|
-
if (
|
|
315
|
-
|
|
204
|
+
} = te(), { login: b } = T(), [h, m] = i(""), [k, N] = i(""), [x, g] = i(!1), [v, f] = i(null), E = {
|
|
205
|
+
google: { icon: fe, label: t("social.google") },
|
|
206
|
+
microsoft: { icon: he, label: t("social.microsoft") }
|
|
207
|
+
}, p = o.filter((w) => w in E).map((w) => ({
|
|
208
|
+
id: w,
|
|
209
|
+
icon: E[w].icon,
|
|
210
|
+
label: E[w].label
|
|
211
|
+
})), { bgClass: C, textClass: M, borderClass: U } = ae(n), z = `${C} bg-gradient-to-r from-white/10 via-white/0 to-white/0`;
|
|
212
|
+
async function L(w) {
|
|
213
|
+
var A;
|
|
214
|
+
if (w.preventDefault(), !x) {
|
|
215
|
+
f(null), g(!0);
|
|
316
216
|
try {
|
|
317
|
-
await
|
|
318
|
-
} catch (
|
|
319
|
-
((
|
|
217
|
+
await b({ email: h, password: k });
|
|
218
|
+
} catch (I) {
|
|
219
|
+
((A = I == null ? void 0 : I.response) == null ? void 0 : A.status) === 401 ? f(t("errors.invalidCredentials")) : f(t("errors.generic"));
|
|
320
220
|
} finally {
|
|
321
221
|
g(!1);
|
|
322
222
|
}
|
|
323
223
|
}
|
|
324
224
|
}
|
|
325
|
-
function
|
|
326
|
-
var
|
|
327
|
-
if (!
|
|
225
|
+
function D(w) {
|
|
226
|
+
var I, $, S;
|
|
227
|
+
if (!u) {
|
|
328
228
|
console.error("Auth baseUrl is not configured.");
|
|
329
229
|
return;
|
|
330
230
|
}
|
|
331
|
-
const
|
|
332
|
-
if (sessionStorage.setItem("postLoginRedirect",
|
|
333
|
-
const
|
|
334
|
-
|
|
231
|
+
const A = (($ = (I = r.state) == null ? void 0 : I.from) == null ? void 0 : $.pathname) || ((S = r.state) == null ? void 0 : S.from) || "/";
|
|
232
|
+
if (sessionStorage.setItem("postLoginRedirect", A), w === "google") {
|
|
233
|
+
const G = "/oauth/google/callback", Y = `${window.location.origin}${G}`, V = new URL(`${u}/auth/google`);
|
|
234
|
+
V.searchParams.set("redirect", Y), window.location.href = V.toString();
|
|
335
235
|
return;
|
|
336
236
|
}
|
|
337
|
-
if (
|
|
338
|
-
const
|
|
339
|
-
|
|
237
|
+
if (w === "microsoft") {
|
|
238
|
+
const G = "/oauth/microsoft/callback", Y = `${window.location.origin}${G}`, V = new URL(`${u}/auth/microsoft`);
|
|
239
|
+
V.searchParams.set("redirect", Y), window.location.href = V.toString();
|
|
340
240
|
return;
|
|
341
241
|
}
|
|
342
242
|
}
|
|
343
|
-
const
|
|
243
|
+
const re = /* @__PURE__ */ e.createElement(
|
|
344
244
|
"svg",
|
|
345
245
|
{
|
|
346
246
|
className: "h-4 w-4 animate-spin stroke-current",
|
|
@@ -358,145 +258,146 @@ const Se = [
|
|
|
358
258
|
}
|
|
359
259
|
)
|
|
360
260
|
);
|
|
361
|
-
return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${
|
|
261
|
+
return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${z}` }, /* @__PURE__ */ e.createElement("div", { className: "flex w-full max-w-5xl bg-white rounded-2xl shadow-2xl overflow-hidden" }, /* @__PURE__ */ e.createElement("div", { className: `hidden md:flex md:w-1/2 p-12 flex-col justify-between text-white ${C}` }, /* @__PURE__ */ e.createElement("div", null, s ? /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-4" }, /* @__PURE__ */ e.createElement(
|
|
362
262
|
"img",
|
|
363
263
|
{
|
|
364
264
|
loading: "lazy",
|
|
365
|
-
src:
|
|
265
|
+
src: s,
|
|
366
266
|
alt: "Brand Logo",
|
|
367
267
|
className: "bg-white h-8 md:h-22 rounded-lg"
|
|
368
268
|
}
|
|
369
|
-
), /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold uppercase" },
|
|
269
|
+
), /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold uppercase" }, l)) : /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold" }, l)), /* @__PURE__ */ e.createElement("div", { className: "flex-1 space-y-4 mt-6 py-4" }, /* @__PURE__ */ e.createElement("h3", { className: "text-2xl font-semibold leading-tight" }, c.title), /* @__PURE__ */ e.createElement("p", { className: "text-base leading-relaxed opacity-90 ltr:text-left rtl:text-right" }, c.description), /* @__PURE__ */ e.createElement("div", { className: "relative" }, /* @__PURE__ */ e.createElement("div", { className: "absolute -left-4 -top-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement("div", { className: "absolute -right-4 -bottom-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement(
|
|
370
270
|
"img",
|
|
371
271
|
{
|
|
372
272
|
loading: "lazy",
|
|
373
|
-
src:
|
|
273
|
+
src: d,
|
|
374
274
|
alt: "Sign in illustration",
|
|
375
275
|
className: "max-w-sm w-full mx-auto rounded-lg shadow-lg transform hover:scale-105 transition-transform duration-300 p-6"
|
|
376
276
|
}
|
|
377
|
-
)))), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-1/2 p-4 md:p-8 m-auto" }, /* @__PURE__ */ e.createElement("div", { className: "flex flex-col md:flex-row justify-between items-center mb-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center md:hidden mb-5" },
|
|
277
|
+
)))), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-1/2 p-4 md:p-8 m-auto" }, /* @__PURE__ */ e.createElement("div", { className: "flex flex-col md:flex-row justify-between items-center mb-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center md:hidden mb-5" }, s ? /* @__PURE__ */ e.createElement(
|
|
378
278
|
"img",
|
|
379
279
|
{
|
|
380
280
|
loading: "lazy",
|
|
381
|
-
src:
|
|
281
|
+
src: s,
|
|
382
282
|
alt: "Brand Logo",
|
|
383
|
-
className: `h-22 rounded-full border ${
|
|
283
|
+
className: `h-22 rounded-full border ${U}`
|
|
384
284
|
}
|
|
385
|
-
) : /* @__PURE__ */ e.createElement("h2", { className: "text-2xl font-bold" },
|
|
285
|
+
) : /* @__PURE__ */ e.createElement("h2", { className: "text-2xl font-bold" }, l)), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-auto mb-4 md:mb-0 text-center md:text-left ltr:text-center rtl:text-center md:ltr:text-left md:rtl:text-right" }, /* @__PURE__ */ e.createElement("p", { className: "text-sm md:text-lg" }, t("SignInPage.welcome"), " ", /* @__PURE__ */ e.createElement("span", { className: `font-semibold ${M} uppercase` }, l)), /* @__PURE__ */ e.createElement("h1", { className: "text-2xl md:text-4xl font-bold text-gray-800" }, t("SignInPage.signIn"))), /* @__PURE__ */ e.createElement("div", { className: "text-sm text-gray-500 text-center md:text-right" }, t("SignInPage.noAccount"), /* @__PURE__ */ e.createElement("br", null), /* @__PURE__ */ e.createElement(
|
|
386
286
|
"button",
|
|
387
287
|
{
|
|
388
288
|
type: "button",
|
|
389
289
|
onClick: () => a("/signup"),
|
|
390
|
-
className:
|
|
290
|
+
className: M
|
|
391
291
|
},
|
|
392
292
|
t("SignInPage.signUp")
|
|
393
|
-
))),
|
|
394
|
-
|
|
293
|
+
))), v && /* @__PURE__ */ e.createElement(le, { message: v }), /* @__PURE__ */ e.createElement("form", { className: "space-y-6", onSubmit: L }, /* @__PURE__ */ e.createElement(
|
|
294
|
+
P,
|
|
395
295
|
{
|
|
396
296
|
label: t("form.emailLabel"),
|
|
397
297
|
type: "email",
|
|
398
298
|
placeholder: t("form.emailPlaceholder"),
|
|
399
|
-
color:
|
|
400
|
-
value:
|
|
401
|
-
onChange:
|
|
299
|
+
color: U,
|
|
300
|
+
value: h,
|
|
301
|
+
onChange: m
|
|
402
302
|
}
|
|
403
303
|
), /* @__PURE__ */ e.createElement(
|
|
404
|
-
|
|
304
|
+
P,
|
|
405
305
|
{
|
|
406
306
|
label: t("form.passwordLabel"),
|
|
407
307
|
type: "password",
|
|
408
308
|
placeholder: t("form.passwordPlaceholder"),
|
|
409
|
-
color:
|
|
410
|
-
value:
|
|
309
|
+
color: U,
|
|
310
|
+
value: k,
|
|
411
311
|
onChange: N
|
|
412
312
|
}
|
|
413
|
-
), /* @__PURE__ */ e.createElement("div", { className: "ltr:text-right rtl:text-left" }, /* @__PURE__ */ e.createElement(
|
|
313
|
+
), /* @__PURE__ */ e.createElement("div", { className: "ltr:text-right rtl:text-left" }, /* @__PURE__ */ e.createElement(Me, { to: "/forgot-password", className: M }, t("SignInPage.forgotPassword"))), /* @__PURE__ */ e.createElement(
|
|
414
314
|
"button",
|
|
415
315
|
{
|
|
416
316
|
type: "submit",
|
|
417
|
-
disabled:
|
|
418
|
-
className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${
|
|
317
|
+
disabled: x,
|
|
318
|
+
className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${x ? "opacity-60 cursor-not-allowed" : ""} ${C} text-white`
|
|
419
319
|
},
|
|
420
|
-
|
|
421
|
-
t(
|
|
422
|
-
),
|
|
320
|
+
x && re,
|
|
321
|
+
t(x ? "SignInPage.signInSubmitting" : "SignInPage.signIn")
|
|
322
|
+
), p.length > 0 && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "flex items-center pt-2" }, /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${C}` }), /* @__PURE__ */ e.createElement("span", { className: `${M} mx-3 text-sm` }, t("SignInPage.orLoginWith")), /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${C}` })), /* @__PURE__ */ e.createElement("div", { className: "flex gap-3 mb-6 justify-center md:justify-start" }, p.map((w) => /* @__PURE__ */ e.createElement(
|
|
423
323
|
"button",
|
|
424
324
|
{
|
|
425
|
-
key:
|
|
325
|
+
key: w.id,
|
|
426
326
|
type: "button",
|
|
427
|
-
onClick: () =>
|
|
327
|
+
onClick: () => D(w.id),
|
|
428
328
|
className: "flex-1"
|
|
429
329
|
},
|
|
430
|
-
/* @__PURE__ */ e.createElement(
|
|
330
|
+
/* @__PURE__ */ e.createElement(ge, { icon: w.icon, label: w.label })
|
|
431
331
|
))))))));
|
|
432
|
-
},
|
|
433
|
-
const t =
|
|
434
|
-
brandName:
|
|
435
|
-
colors:
|
|
436
|
-
logoUrl:
|
|
332
|
+
}, je = () => {
|
|
333
|
+
const t = Z("authLib"), a = q(), r = ee(), {
|
|
334
|
+
brandName: l = t("brandName", { defaultValue: "MyBrand" }),
|
|
335
|
+
colors: n = { bg: "bg-sky-500", text: "text-white", border: "border-sky-500" },
|
|
336
|
+
logoUrl: s,
|
|
437
337
|
oauthProviders: o = [],
|
|
438
|
-
illustrationUrl:
|
|
338
|
+
illustrationUrl: d = t("community.illustrationUrl", {
|
|
439
339
|
defaultValue: "https://cdn.builder.io/api/v1/image/assets/TEMP/35ba84b8335fda2819c3a14ea3d00321a0fd0e79e571caa31108468010868ca5?placeholderIfAbsent=true&apiKey=a460e9a46e514356ac1106eada03046c"
|
|
440
340
|
}),
|
|
441
|
-
communityContent:
|
|
341
|
+
communityContent: c = {
|
|
442
342
|
title: t("community.title"),
|
|
443
343
|
description: t("community.description")
|
|
444
344
|
},
|
|
445
|
-
baseUrl:
|
|
345
|
+
baseUrl: u
|
|
446
346
|
// IMPORTANT: used for OAuth redirect (same as SignIn)
|
|
447
|
-
} =
|
|
448
|
-
google: { icon:
|
|
449
|
-
microsoft: { icon:
|
|
450
|
-
},
|
|
451
|
-
id:
|
|
452
|
-
icon:
|
|
453
|
-
label:
|
|
454
|
-
})), { bgClass:
|
|
455
|
-
async function
|
|
456
|
-
var
|
|
457
|
-
if (
|
|
458
|
-
|
|
347
|
+
} = te(), { login: b, api: h } = T(), [m, k] = i(""), [N, x] = i(""), [g, v] = i(""), [f, E] = i(""), [p, C] = i(""), [M, U] = i(!1), [z, L] = i(null), [D, re] = i(!1), w = {
|
|
348
|
+
google: { icon: fe, label: t("social.google") },
|
|
349
|
+
microsoft: { icon: he, label: t("social.microsoft") }
|
|
350
|
+
}, A = o.filter((y) => y in w).map((y) => ({
|
|
351
|
+
id: y,
|
|
352
|
+
icon: w[y].icon,
|
|
353
|
+
label: w[y].label
|
|
354
|
+
})), { bgClass: I, textClass: $, borderClass: S } = ae(n), G = `${I} bg-gradient-to-r from-white/10 via-white/0 to-white/0`;
|
|
355
|
+
async function Y(y) {
|
|
356
|
+
var _, O, H;
|
|
357
|
+
if (y.preventDefault(), !M) {
|
|
358
|
+
L(null), U(!0);
|
|
459
359
|
try {
|
|
460
|
-
await
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
360
|
+
await h.post("/api/auth/register", {
|
|
361
|
+
fullname: { fname: m, lname: N },
|
|
362
|
+
username: g,
|
|
363
|
+
email: f,
|
|
364
|
+
password: p
|
|
365
|
+
}), await b({ email: f, password: p });
|
|
366
|
+
} catch (j) {
|
|
367
|
+
const F = (_ = j == null ? void 0 : j.response) == null ? void 0 : _.status;
|
|
368
|
+
L(
|
|
369
|
+
F === 400 ? ((H = (O = j == null ? void 0 : j.response) == null ? void 0 : O.data) == null ? void 0 : H.message) || t("errors.invalidData", {
|
|
469
370
|
defaultValue: "Please check the fields and try again."
|
|
470
|
-
}) :
|
|
371
|
+
}) : F === 409 ? t("errors.emailInUse", {
|
|
471
372
|
defaultValue: "This email is already in use."
|
|
472
373
|
}) : t("errors.generic", {
|
|
473
374
|
defaultValue: "Something went wrong. Please try again."
|
|
474
375
|
})
|
|
475
376
|
);
|
|
476
377
|
} finally {
|
|
477
|
-
|
|
378
|
+
U(!1);
|
|
478
379
|
}
|
|
479
380
|
}
|
|
480
381
|
}
|
|
481
|
-
function
|
|
482
|
-
var
|
|
483
|
-
if (!
|
|
382
|
+
function V(y) {
|
|
383
|
+
var O, H, j;
|
|
384
|
+
if (!u) {
|
|
484
385
|
console.error("Auth baseUrl is not configured.");
|
|
485
386
|
return;
|
|
486
387
|
}
|
|
487
|
-
const
|
|
488
|
-
if (sessionStorage.setItem("postLoginRedirect",
|
|
489
|
-
const
|
|
490
|
-
|
|
388
|
+
const _ = ((H = (O = r.state) == null ? void 0 : O.from) == null ? void 0 : H.pathname) || ((j = r.state) == null ? void 0 : j.from) || "/";
|
|
389
|
+
if (sessionStorage.setItem("postLoginRedirect", _), y === "google") {
|
|
390
|
+
const F = "/oauth/google/callback", se = `${window.location.origin}${F}`, Q = new URL(`${u}/auth/google`);
|
|
391
|
+
Q.searchParams.set("redirect", se), window.location.href = Q.toString();
|
|
491
392
|
return;
|
|
492
393
|
}
|
|
493
|
-
if (
|
|
494
|
-
const
|
|
495
|
-
|
|
394
|
+
if (y === "microsoft") {
|
|
395
|
+
const F = "/oauth/microsoft/callback", se = `${window.location.origin}${F}`, Q = new URL(`${u}/auth/microsoft`);
|
|
396
|
+
Q.searchParams.set("redirect", se), window.location.href = Q.toString();
|
|
496
397
|
return;
|
|
497
398
|
}
|
|
498
399
|
}
|
|
499
|
-
const
|
|
400
|
+
const be = /* @__PURE__ */ e.createElement(
|
|
500
401
|
"svg",
|
|
501
402
|
{
|
|
502
403
|
className: "h-4 w-4 animate-spin stroke-current",
|
|
@@ -514,285 +415,428 @@ const Se = [
|
|
|
514
415
|
}
|
|
515
416
|
)
|
|
516
417
|
);
|
|
517
|
-
return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${
|
|
418
|
+
return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${G}` }, /* @__PURE__ */ e.createElement("div", { className: "flex w-full max-w-5xl bg-white rounded-2xl shadow-2xl overflow-hidden" }, /* @__PURE__ */ e.createElement("div", { className: `hidden md:flex md:w-1/2 p-12 flex-col justify-between text-white ${I}` }, /* @__PURE__ */ e.createElement("div", null, s ? /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-4" }, /* @__PURE__ */ e.createElement(
|
|
518
419
|
"img",
|
|
519
420
|
{
|
|
520
421
|
loading: "lazy",
|
|
521
|
-
src:
|
|
422
|
+
src: s,
|
|
522
423
|
alt: "Brand Logo",
|
|
523
424
|
className: "bg-white h-8 md:h-22 rounded-lg"
|
|
524
425
|
}
|
|
525
|
-
), /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold uppercase" },
|
|
426
|
+
), /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold uppercase" }, l)) : /* @__PURE__ */ e.createElement("h2", { className: "text-sm md:text-2xl font-bold" }, l)), /* @__PURE__ */ e.createElement("div", { className: "flex-1 space-y-4 mt-6 py-4" }, /* @__PURE__ */ e.createElement("h3", { className: "text-2xl font-semibold leading-tight" }, c.title), /* @__PURE__ */ e.createElement("p", { className: "text-base leading-relaxed opacity-90 ltr:text-left rtl:text-right" }, c.description), /* @__PURE__ */ e.createElement("div", { className: "relative" }, /* @__PURE__ */ e.createElement("div", { className: "absolute -left-4 -top-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement("div", { className: "absolute -right-4 -bottom-4 w-20 h-20 bg-white/20 rounded-full blur-xl" }), /* @__PURE__ */ e.createElement(
|
|
526
427
|
"img",
|
|
527
428
|
{
|
|
528
429
|
loading: "lazy",
|
|
529
|
-
src:
|
|
430
|
+
src: d,
|
|
530
431
|
alt: "Sign up illustration",
|
|
531
432
|
className: "max-w-sm w-full mx-auto rounded-lg shadow-lg transform hover:scale-105 transition-transform duration-300 p-6"
|
|
532
433
|
}
|
|
533
|
-
)))), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-1/2 p-4 md:p-8 m-auto" }, /* @__PURE__ */ e.createElement("div", { className: "flex flex-col md:flex-row justify-between items-center mb-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center md:hidden mb-5" },
|
|
434
|
+
)))), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-1/2 p-4 md:p-8 m-auto" }, /* @__PURE__ */ e.createElement("div", { className: "flex flex-col md:flex-row justify-between items-center mb-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center md:hidden mb-5" }, s ? /* @__PURE__ */ e.createElement(
|
|
534
435
|
"img",
|
|
535
436
|
{
|
|
536
437
|
loading: "lazy",
|
|
537
|
-
src:
|
|
438
|
+
src: s,
|
|
538
439
|
alt: "Brand Logo",
|
|
539
|
-
className: `h-22 rounded-full border ${
|
|
440
|
+
className: `h-22 rounded-full border ${S}`
|
|
540
441
|
}
|
|
541
|
-
) : /* @__PURE__ */ e.createElement("h2", { className: "text-2xl font-bold" },
|
|
442
|
+
) : /* @__PURE__ */ e.createElement("h2", { className: "text-2xl font-bold" }, l)), /* @__PURE__ */ e.createElement("div", { className: "w-full md:w-auto mb-4 md:mb-0 text-center md:text-left ltr:text-center rtl:text-center md:ltr:text-left md:rtl:text-right" }, /* @__PURE__ */ e.createElement("p", { className: "text-sm md:text-lg" }, t("SignUpPage.welcome", { defaultValue: "Join" }), " ", /* @__PURE__ */ e.createElement("span", { className: `font-semibold ${$} uppercase` }, l)), /* @__PURE__ */ e.createElement("h1", { className: "text-2xl md:text-4xl font-bold text-gray-800" }, t("SignUpPage.signUp", { defaultValue: "Sign up" }))), /* @__PURE__ */ e.createElement("div", { className: "text-sm text-gray-500 text-center md:text-right" }, t("SignUpPage.alreadyHaveAccount", {
|
|
542
443
|
defaultValue: "Already have an account?"
|
|
543
444
|
}), /* @__PURE__ */ e.createElement("br", null), /* @__PURE__ */ e.createElement(
|
|
544
445
|
"button",
|
|
545
446
|
{
|
|
546
447
|
type: "button",
|
|
547
448
|
onClick: () => a("/login"),
|
|
548
|
-
className:
|
|
449
|
+
className: $
|
|
549
450
|
},
|
|
550
451
|
t("SignUpPage.signIn", { defaultValue: "Sign in" })
|
|
551
|
-
))),
|
|
552
|
-
|
|
452
|
+
))), z && /* @__PURE__ */ e.createElement(le, { message: z }), /* @__PURE__ */ e.createElement("form", { className: "space-y-6", onSubmit: Y }, /* @__PURE__ */ e.createElement("div", { className: "flex gap-2" }, /* @__PURE__ */ e.createElement(
|
|
453
|
+
P,
|
|
553
454
|
{
|
|
554
|
-
label: t("form.
|
|
455
|
+
label: t("form.fnameLabel", { defaultValue: "First Name" }),
|
|
555
456
|
type: "text",
|
|
556
|
-
placeholder: t("form.
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
value: E,
|
|
561
|
-
onChange: C
|
|
457
|
+
placeholder: t("form.fnamePlaceholder", { defaultValue: "Enter your first name" }),
|
|
458
|
+
color: S,
|
|
459
|
+
value: m,
|
|
460
|
+
onChange: k
|
|
562
461
|
}
|
|
563
462
|
), /* @__PURE__ */ e.createElement(
|
|
564
|
-
|
|
463
|
+
P,
|
|
464
|
+
{
|
|
465
|
+
label: t("form.lnameLabel", { defaultValue: "Last Name" }),
|
|
466
|
+
type: "text",
|
|
467
|
+
placeholder: t("form.lnamePlaceholder", { defaultValue: "Enter your last name" }),
|
|
468
|
+
color: S,
|
|
469
|
+
value: N,
|
|
470
|
+
onChange: x
|
|
471
|
+
}
|
|
472
|
+
)), /* @__PURE__ */ e.createElement(
|
|
473
|
+
P,
|
|
474
|
+
{
|
|
475
|
+
label: t("form.usernameLabel", { defaultValue: "Username" }),
|
|
476
|
+
type: "text",
|
|
477
|
+
placeholder: t("form.usernamePlaceholder", { defaultValue: "Choose a username" }),
|
|
478
|
+
color: S,
|
|
479
|
+
value: g,
|
|
480
|
+
onChange: v
|
|
481
|
+
}
|
|
482
|
+
), /* @__PURE__ */ e.createElement(
|
|
483
|
+
P,
|
|
565
484
|
{
|
|
566
485
|
label: t("form.emailLabel"),
|
|
567
486
|
type: "email",
|
|
568
487
|
placeholder: t("form.emailPlaceholder"),
|
|
569
|
-
color:
|
|
570
|
-
value:
|
|
571
|
-
onChange:
|
|
488
|
+
color: S,
|
|
489
|
+
value: f,
|
|
490
|
+
onChange: E
|
|
572
491
|
}
|
|
573
492
|
), /* @__PURE__ */ e.createElement(
|
|
574
|
-
|
|
493
|
+
P,
|
|
575
494
|
{
|
|
576
495
|
label: t("form.passwordLabel"),
|
|
577
496
|
type: "password",
|
|
578
497
|
placeholder: t("form.passwordPlaceholder"),
|
|
579
|
-
color:
|
|
580
|
-
value:
|
|
581
|
-
onChange:
|
|
498
|
+
color: S,
|
|
499
|
+
value: p,
|
|
500
|
+
onChange: C
|
|
582
501
|
}
|
|
583
|
-
), /* @__PURE__ */ e.createElement(
|
|
502
|
+
), /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ e.createElement(
|
|
503
|
+
"input",
|
|
504
|
+
{
|
|
505
|
+
id: "agree",
|
|
506
|
+
type: "checkbox",
|
|
507
|
+
checked: D,
|
|
508
|
+
onChange: (y) => re(y.target.checked),
|
|
509
|
+
className: "form-checkbox"
|
|
510
|
+
}
|
|
511
|
+
), /* @__PURE__ */ e.createElement("label", { htmlFor: "agree", className: "text-sm" }, "I agree to the ", /* @__PURE__ */ e.createElement("span", { className: "underline cursor-pointer" }, "terms and conditions"), " (placeholder)")), /* @__PURE__ */ e.createElement(
|
|
584
512
|
"button",
|
|
585
513
|
{
|
|
586
514
|
type: "submit",
|
|
587
|
-
disabled:
|
|
588
|
-
className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${
|
|
515
|
+
disabled: M,
|
|
516
|
+
className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${M ? "opacity-60 cursor-not-allowed" : ""} ${I} text-white`
|
|
589
517
|
},
|
|
590
|
-
|
|
591
|
-
|
|
518
|
+
M && be,
|
|
519
|
+
M ? t("SignUpPage.signUpSubmitting", {
|
|
592
520
|
defaultValue: "Creating account..."
|
|
593
521
|
}) : t("SignUpPage.signUp", { defaultValue: "Sign up" })
|
|
594
|
-
),
|
|
522
|
+
), A.length > 0 && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "flex items-center pt-2" }, /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${I}` }), /* @__PURE__ */ e.createElement("span", { className: `${$} mx-3 text-sm` }, t("SignUpPage.orContinueWith", {
|
|
595
523
|
defaultValue: "Or continue with"
|
|
596
|
-
})), /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${
|
|
524
|
+
})), /* @__PURE__ */ e.createElement("div", { className: `flex-grow h-px ${I}` })), /* @__PURE__ */ e.createElement("div", { className: "flex gap-3 mb-6 justify-center md:justify-start" }, A.map((y) => /* @__PURE__ */ e.createElement(
|
|
597
525
|
"button",
|
|
598
526
|
{
|
|
599
|
-
key:
|
|
527
|
+
key: y.id,
|
|
600
528
|
type: "button",
|
|
601
|
-
onClick: () =>
|
|
529
|
+
onClick: () => V(y.id),
|
|
602
530
|
className: "flex-1"
|
|
603
531
|
},
|
|
604
|
-
/* @__PURE__ */ e.createElement(
|
|
532
|
+
/* @__PURE__ */ e.createElement(ge, { icon: y.icon, label: y.label })
|
|
605
533
|
))))))));
|
|
606
|
-
},
|
|
607
|
-
const t = new URLSearchParams(window.location.search), a = t.get("accessToken"),
|
|
608
|
-
a && localStorage.setItem("authToken", a),
|
|
609
|
-
const
|
|
610
|
-
sessionStorage.removeItem("postLoginRedirect"), window.location.replace(
|
|
611
|
-
}, []), /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center min-h-screen text-gray-700" }, "Finishing Google sign-in…")),
|
|
612
|
-
const {
|
|
613
|
-
|
|
534
|
+
}, me = () => (W(() => {
|
|
535
|
+
const t = new URLSearchParams(window.location.search), a = t.get("accessToken"), r = t.get("refreshToken");
|
|
536
|
+
a && localStorage.setItem("authToken", a), r && localStorage.setItem("refreshToken", r);
|
|
537
|
+
const l = sessionStorage.getItem("postLoginRedirect") || "/";
|
|
538
|
+
sessionStorage.removeItem("postLoginRedirect"), window.location.replace(l);
|
|
539
|
+
}, []), /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-center min-h-screen text-gray-700" }, "Finishing Google sign-in…")), Te = () => {
|
|
540
|
+
const t = Z("authLib"), a = q(), { colors: r, brandName: l = t("brandName", { defaultValue: "MyBrand" }), logoUrl: n } = te(), { api: s } = T(), { bgClass: o, textClass: d, borderClass: c } = ae(r), u = `${o} bg-gradient-to-r from-white/10 via-white/0 to-white/0`, [b, h] = i(""), [m, k] = i(!1), [N, x] = i(null), [g, v] = i(!1);
|
|
541
|
+
async function f(E) {
|
|
542
|
+
if (E.preventDefault(), !m) {
|
|
543
|
+
x(null), k(!0);
|
|
544
|
+
try {
|
|
545
|
+
await s.post("/api/auth/forgot-password", { email: b }), v(!0);
|
|
546
|
+
} catch (p) {
|
|
547
|
+
v(!0), console.error("Forgot password request failed", p);
|
|
548
|
+
} finally {
|
|
549
|
+
k(!1);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${u}` }, /* @__PURE__ */ e.createElement("div", { className: "flex w-full max-w-xl bg-white rounded-2xl shadow-2xl overflow-hidden" }, /* @__PURE__ */ e.createElement("div", { className: "w-full p-6 md:p-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-between mb-6" }, n ? /* @__PURE__ */ e.createElement(
|
|
554
|
+
"img",
|
|
555
|
+
{
|
|
556
|
+
loading: "lazy",
|
|
557
|
+
src: n,
|
|
558
|
+
alt: "Brand Logo",
|
|
559
|
+
className: `h-10 rounded-lg border ${c}`
|
|
560
|
+
}
|
|
561
|
+
) : /* @__PURE__ */ e.createElement("h2", { className: "text-xl font-bold" }, l), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => a("/login"), className: `text-sm ${d}` }, t("ForgotPasswordPage.backToLogin", { defaultValue: "Back to Sign In" }))), /* @__PURE__ */ e.createElement("h1", { className: "text-2xl md:text-3xl font-bold text-gray-800" }, t("ForgotPasswordPage.title", { defaultValue: "Forgot your password?" })), /* @__PURE__ */ e.createElement("p", { className: "mt-2 text-sm text-gray-600" }, t("ForgotPasswordPage.subtitle", { defaultValue: "Enter your email to receive a reset link." })), N && /* @__PURE__ */ e.createElement(le, { message: N }), g ? /* @__PURE__ */ e.createElement("div", { className: "mt-6 rounded-lg border border-green-300 bg-green-50 p-4 text-green-800 text-sm" }, t("ForgotPasswordPage.sent", {
|
|
562
|
+
defaultValue: "If the email exists, we’ve sent a reset link. Please check your inbox."
|
|
563
|
+
})) : /* @__PURE__ */ e.createElement("form", { className: "space-y-6 mt-4", onSubmit: f }, /* @__PURE__ */ e.createElement(
|
|
564
|
+
P,
|
|
565
|
+
{
|
|
566
|
+
label: t("form.emailLabel"),
|
|
567
|
+
type: "email",
|
|
568
|
+
placeholder: t("form.emailPlaceholder"),
|
|
569
|
+
color: c,
|
|
570
|
+
value: b,
|
|
571
|
+
onChange: h
|
|
572
|
+
}
|
|
573
|
+
), /* @__PURE__ */ e.createElement(
|
|
574
|
+
"button",
|
|
575
|
+
{
|
|
576
|
+
type: "submit",
|
|
577
|
+
disabled: m || !b,
|
|
578
|
+
className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${m ? "opacity-60 cursor-not-allowed" : ""} ${o} text-white`
|
|
579
|
+
},
|
|
580
|
+
m && /* @__PURE__ */ e.createElement("svg", { className: "h-4 w-4 animate-spin stroke-current", viewBox: "0 0 24 24", fill: "none" }, /* @__PURE__ */ e.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", strokeWidth: "4" }), /* @__PURE__ */ e.createElement("path", { className: "opacity-75", d: "M4 12a8 8 0 018-8", strokeWidth: "4", strokeLinecap: "round" })),
|
|
581
|
+
t("ForgotPasswordPage.sendLink", { defaultValue: "Send Reset Link" })
|
|
582
|
+
)))));
|
|
583
|
+
}, Ue = () => {
|
|
584
|
+
const t = Z("authLib"), a = q(), r = ee(), { colors: l, brandName: n = t("brandName", { defaultValue: "MyBrand" }), logoUrl: s } = te(), { api: o } = T(), { bgClass: d, textClass: c, borderClass: u } = ae(l), b = `${d} bg-gradient-to-r from-white/10 via-white/0 to-white/0`, h = J(() => new URLSearchParams(r.search).get("token"), [r.search]), [m, k] = i(""), [N, x] = i(""), [g, v] = i(!1), [f, E] = i(null), p = 6, C = h && m.length >= p && m === N;
|
|
585
|
+
async function M(U) {
|
|
586
|
+
var z;
|
|
587
|
+
if (U.preventDefault(), !g) {
|
|
588
|
+
if (E(null), !h) {
|
|
589
|
+
E(t("ResetPasswordPage.invalidLink", { defaultValue: "Invalid reset link." }));
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (m.length < p) {
|
|
593
|
+
E(
|
|
594
|
+
t("ResetPasswordPage.tooShort", { defaultValue: `Password must be at least ${p} characters.` })
|
|
595
|
+
);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
if (m !== N) {
|
|
599
|
+
E(t("ResetPasswordPage.mismatch", { defaultValue: "Passwords do not match." }));
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
v(!0);
|
|
603
|
+
try {
|
|
604
|
+
await o.post("/api/auth/reset-password", { token: h, newPassword: m }), a("/login", { replace: !0 });
|
|
605
|
+
} catch (L) {
|
|
606
|
+
const D = (z = L == null ? void 0 : L.response) == null ? void 0 : z.status;
|
|
607
|
+
E(
|
|
608
|
+
D === 400 || D === 401 || D === 410 ? t("ResetPasswordPage.invalidOrExpired", {
|
|
609
|
+
defaultValue: "Reset link is invalid or has expired. Request a new one."
|
|
610
|
+
}) : t("errors.generic", { defaultValue: "Something went wrong. Please try again." })
|
|
611
|
+
);
|
|
612
|
+
} finally {
|
|
613
|
+
v(!1);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return /* @__PURE__ */ e.createElement("div", { className: `flex items-center justify-center min-h-screen p-4 ${b}` }, /* @__PURE__ */ e.createElement("div", { className: "flex w-full max-w-xl bg-white rounded-2xl shadow-2xl overflow-hidden" }, /* @__PURE__ */ e.createElement("div", { className: "w-full p-6 md:p-8" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-between mb-6" }, s ? /* @__PURE__ */ e.createElement(
|
|
618
|
+
"img",
|
|
619
|
+
{
|
|
620
|
+
loading: "lazy",
|
|
621
|
+
src: s,
|
|
622
|
+
alt: "Brand Logo",
|
|
623
|
+
className: `h-10 rounded-lg border ${u}`
|
|
624
|
+
}
|
|
625
|
+
) : /* @__PURE__ */ e.createElement("h2", { className: "text-xl font-bold" }, n), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => a("/login"), className: `text-sm ${c}` }, t("ResetPasswordPage.backToLogin", { defaultValue: "Back to Sign In" }))), /* @__PURE__ */ e.createElement("h1", { className: "text-2xl md:text-3xl font-bold text-gray-800" }, t("ResetPasswordPage.title", { defaultValue: "Reset your password" })), /* @__PURE__ */ e.createElement("p", { className: "mt-2 text-sm text-gray-600" }, t("ResetPasswordPage.subtitle", { defaultValue: "Choose a new password to access your account." })), f && /* @__PURE__ */ e.createElement(le, { message: f }), !h && /* @__PURE__ */ e.createElement("div", { className: "mt-6 rounded-lg border border-red-300 bg-red-50 p-4 text-red-800 text-sm" }, t("ResetPasswordPage.invalidLink", { defaultValue: "Invalid reset link." })), /* @__PURE__ */ e.createElement("form", { className: "space-y-6 mt-4", onSubmit: M }, /* @__PURE__ */ e.createElement(
|
|
626
|
+
P,
|
|
627
|
+
{
|
|
628
|
+
label: t("form.passwordLabel"),
|
|
629
|
+
type: "password",
|
|
630
|
+
placeholder: t("form.passwordPlaceholder"),
|
|
631
|
+
color: u,
|
|
632
|
+
value: m,
|
|
633
|
+
onChange: k
|
|
634
|
+
}
|
|
635
|
+
), /* @__PURE__ */ e.createElement(
|
|
636
|
+
P,
|
|
637
|
+
{
|
|
638
|
+
label: t("ResetPasswordPage.confirmLabel", { defaultValue: "Confirm Password" }),
|
|
639
|
+
type: "password",
|
|
640
|
+
placeholder: t("ResetPasswordPage.confirmPlaceholder", { defaultValue: "Re-enter your password" }),
|
|
641
|
+
color: u,
|
|
642
|
+
value: N,
|
|
643
|
+
onChange: x
|
|
644
|
+
}
|
|
645
|
+
), /* @__PURE__ */ e.createElement(
|
|
646
|
+
"button",
|
|
647
|
+
{
|
|
648
|
+
type: "submit",
|
|
649
|
+
disabled: g || !C,
|
|
650
|
+
className: `relative flex w-full items-center justify-center gap-2 py-3 rounded-lg font-medium transition-colors ${g ? "opacity-60 cursor-not-allowed" : ""} ${d} text-white`
|
|
651
|
+
},
|
|
652
|
+
g && /* @__PURE__ */ e.createElement("svg", { className: "h-4 w-4 animate-spin stroke-current", viewBox: "0 0 24 24", fill: "none" }, /* @__PURE__ */ e.createElement("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", strokeWidth: "4" }), /* @__PURE__ */ e.createElement("path", { className: "opacity-75", d: "M4 12a8 8 0 018-8", strokeWidth: "4", strokeLinecap: "round" })),
|
|
653
|
+
t("ResetPasswordPage.submit", { defaultValue: "Reset Password" })
|
|
654
|
+
)))));
|
|
655
|
+
}, ze = ({ children: t }) => {
|
|
656
|
+
const { isAuthenticated: a } = T(), r = ee();
|
|
657
|
+
return a ? t : /* @__PURE__ */ e.createElement(K, { to: "/login", state: { from: r }, replace: !0 });
|
|
614
658
|
}, We = ({ config: t, children: a }) => {
|
|
615
|
-
const
|
|
659
|
+
const r = q(), [l, n] = i(
|
|
616
660
|
() => localStorage.getItem("authToken")
|
|
617
|
-
), [
|
|
618
|
-
async function
|
|
661
|
+
), [s, o] = i(null), [d, c] = i(!0), [u, b] = i(!1);
|
|
662
|
+
async function h() {
|
|
619
663
|
try {
|
|
620
|
-
await
|
|
621
|
-
} catch (
|
|
622
|
-
console.warn("Logout endpoint failed, proceeding with local logout:",
|
|
664
|
+
await m.post("/auth/logout");
|
|
665
|
+
} catch (x) {
|
|
666
|
+
console.warn("Logout endpoint failed, proceeding with local logout:", x);
|
|
623
667
|
}
|
|
624
|
-
|
|
668
|
+
n(null), o(null), localStorage.removeItem("authToken"), sessionStorage.clear(), b(!1), r("/login", { replace: !0 });
|
|
625
669
|
}
|
|
626
|
-
const
|
|
627
|
-
const
|
|
670
|
+
const m = J(() => {
|
|
671
|
+
const x = oe.create({
|
|
628
672
|
baseURL: t.baseUrl,
|
|
629
673
|
withCredentials: !0
|
|
630
674
|
});
|
|
631
|
-
return
|
|
675
|
+
return Pe(x, {
|
|
632
676
|
baseUrl: t.baseUrl,
|
|
633
|
-
getAccessToken: () =>
|
|
634
|
-
setAccessToken: (g) =>
|
|
635
|
-
logout: () =>
|
|
636
|
-
}),
|
|
637
|
-
}, [t.baseUrl,
|
|
638
|
-
|
|
677
|
+
getAccessToken: () => l,
|
|
678
|
+
setAccessToken: (g) => n(g),
|
|
679
|
+
logout: () => b(!0)
|
|
680
|
+
}), x;
|
|
681
|
+
}, [t.baseUrl, l]);
|
|
682
|
+
W(() => {
|
|
639
683
|
(async () => {
|
|
640
|
-
if (
|
|
641
|
-
o(
|
|
684
|
+
if (l) {
|
|
685
|
+
o(ne(l)), c(!1);
|
|
642
686
|
return;
|
|
643
687
|
}
|
|
644
688
|
try {
|
|
645
|
-
const { data: g } = await
|
|
689
|
+
const { data: g } = await oe.post(
|
|
646
690
|
`${t.baseUrl}/auth/refresh-token`,
|
|
647
691
|
{},
|
|
648
692
|
{ withCredentials: !0 }
|
|
649
693
|
);
|
|
650
|
-
|
|
694
|
+
n(g.accessToken), o(ne(g.accessToken)), localStorage.setItem("authToken", g.accessToken);
|
|
651
695
|
} catch {
|
|
652
696
|
} finally {
|
|
653
|
-
|
|
697
|
+
c(!1);
|
|
654
698
|
}
|
|
655
699
|
})();
|
|
656
|
-
}, [
|
|
657
|
-
async function
|
|
658
|
-
const { data: g } = await
|
|
659
|
-
|
|
700
|
+
}, [l, t.baseUrl]);
|
|
701
|
+
async function k(x) {
|
|
702
|
+
const { data: g } = await m.post("/api/auth/login", x);
|
|
703
|
+
n(g.accessToken), o(ne(g.accessToken)), localStorage.setItem("authToken", g.accessToken), Le(), r("/", { replace: !0 });
|
|
660
704
|
}
|
|
661
|
-
const N =
|
|
705
|
+
const N = J(
|
|
662
706
|
() => ({
|
|
663
|
-
isAuthenticated: !!
|
|
664
|
-
accessToken:
|
|
665
|
-
user:
|
|
666
|
-
login:
|
|
667
|
-
logout:
|
|
668
|
-
api:
|
|
707
|
+
isAuthenticated: !!l,
|
|
708
|
+
accessToken: l,
|
|
709
|
+
user: s,
|
|
710
|
+
login: k,
|
|
711
|
+
logout: h,
|
|
712
|
+
api: m,
|
|
669
713
|
setUser: o
|
|
670
714
|
}),
|
|
671
|
-
[
|
|
715
|
+
[l, s, m]
|
|
672
716
|
);
|
|
673
|
-
return /* @__PURE__ */ e.createElement(
|
|
674
|
-
|
|
717
|
+
return /* @__PURE__ */ e.createElement(de.Provider, { value: t }, /* @__PURE__ */ e.createElement(ue.Provider, { value: N }, /* @__PURE__ */ e.createElement(Ie, null, /* @__PURE__ */ e.createElement(
|
|
718
|
+
B,
|
|
675
719
|
{
|
|
676
720
|
path: "login",
|
|
677
|
-
element:
|
|
721
|
+
element: l ? /* @__PURE__ */ e.createElement(K, { to: "/", replace: !0 }) : /* @__PURE__ */ e.createElement(Se, { baseUrl: t.baseUrl, colors: t.colors })
|
|
678
722
|
}
|
|
679
723
|
), /* @__PURE__ */ e.createElement(
|
|
680
|
-
|
|
724
|
+
B,
|
|
681
725
|
{
|
|
682
726
|
path: "signup",
|
|
683
|
-
element:
|
|
727
|
+
element: l ? /* @__PURE__ */ e.createElement(K, { to: "/", replace: !0 }) : /* @__PURE__ */ e.createElement(je, null)
|
|
684
728
|
}
|
|
685
|
-
), /* @__PURE__ */ e.createElement(
|
|
686
|
-
|
|
729
|
+
), /* @__PURE__ */ e.createElement(B, { path: "forgot-password", element: /* @__PURE__ */ e.createElement(Te, null) }), /* @__PURE__ */ e.createElement(B, { path: "reset-password", element: /* @__PURE__ */ e.createElement(Ue, null) }), /* @__PURE__ */ e.createElement(
|
|
730
|
+
B,
|
|
687
731
|
{
|
|
688
732
|
path: "oauth/google/callback",
|
|
689
|
-
element: /* @__PURE__ */ e.createElement(
|
|
733
|
+
element: /* @__PURE__ */ e.createElement(me, null)
|
|
690
734
|
}
|
|
691
735
|
), /* @__PURE__ */ e.createElement(
|
|
692
|
-
|
|
736
|
+
B,
|
|
693
737
|
{
|
|
694
738
|
path: "/oauth/microsoft/callback",
|
|
695
|
-
element: /* @__PURE__ */ e.createElement(
|
|
739
|
+
element: /* @__PURE__ */ e.createElement(me, null)
|
|
696
740
|
}
|
|
697
741
|
), /* @__PURE__ */ e.createElement(
|
|
698
|
-
|
|
742
|
+
B,
|
|
699
743
|
{
|
|
700
744
|
path: "*",
|
|
701
745
|
element: /* @__PURE__ */ e.createElement(ze, null, a)
|
|
702
746
|
}
|
|
703
|
-
)),
|
|
747
|
+
)), u && /* @__PURE__ */ e.createElement(Ce, { onConfirm: h })));
|
|
704
748
|
};
|
|
705
|
-
function
|
|
706
|
-
const { user: a } =
|
|
707
|
-
return t.some((
|
|
749
|
+
function pe(...t) {
|
|
750
|
+
const { user: a } = T(), r = (a == null ? void 0 : a.roles) ?? [];
|
|
751
|
+
return t.some((l) => r.includes(l));
|
|
708
752
|
}
|
|
709
753
|
function Ze(t) {
|
|
710
|
-
const { user: a } =
|
|
754
|
+
const { user: a } = T();
|
|
711
755
|
return (a == null ? void 0 : a.modules.includes(t)) ?? !1;
|
|
712
756
|
}
|
|
713
|
-
function
|
|
714
|
-
const { user: a } =
|
|
715
|
-
return t.every((
|
|
757
|
+
function ie(...t) {
|
|
758
|
+
const { user: a } = T(), r = (a == null ? void 0 : a.permissions) ?? [];
|
|
759
|
+
return t.every((l) => r.includes(l));
|
|
716
760
|
}
|
|
717
|
-
const
|
|
761
|
+
const Ge = ({
|
|
718
762
|
children: t,
|
|
719
763
|
fallbackpermessions: a = [],
|
|
720
|
-
anyPermessions:
|
|
721
|
-
fallbackRoles:
|
|
722
|
-
redirectTo:
|
|
764
|
+
anyPermessions: r = [],
|
|
765
|
+
fallbackRoles: l = ["super-admin"],
|
|
766
|
+
redirectTo: n = "/dashboard"
|
|
723
767
|
}) => {
|
|
724
|
-
if (
|
|
768
|
+
if (l.some((c) => pe(c)))
|
|
725
769
|
return /* @__PURE__ */ e.createElement(e.Fragment, null, t);
|
|
726
|
-
const o = a.length === 0 || a.every((
|
|
727
|
-
return o &&
|
|
728
|
-
}, xe = e.createContext({}),
|
|
729
|
-
function
|
|
730
|
-
var
|
|
731
|
-
const
|
|
732
|
-
return
|
|
770
|
+
const o = a.length === 0 || a.every((c) => ie(c)), d = r.length === 0 || r.some((c) => ie(c));
|
|
771
|
+
return o && d ? /* @__PURE__ */ e.createElement(e.Fragment, null, t) : /* @__PURE__ */ e.createElement(K, { to: n, replace: !0 });
|
|
772
|
+
}, xe = e.createContext({}), Ye = xe.Provider;
|
|
773
|
+
function Oe(t, a) {
|
|
774
|
+
var n, s, o;
|
|
775
|
+
const l = (n = e.useContext(xe)[t]) == null ? void 0 : n[a];
|
|
776
|
+
return l ? !!((s = l.perms) != null && s.some((d) => ie(d)) || (o = l.fallbackRoles) != null && o.some((d) => pe(d))) : !1;
|
|
733
777
|
}
|
|
734
|
-
const
|
|
735
|
-
const { user: t, api: a, setUser:
|
|
778
|
+
const He = () => {
|
|
779
|
+
const { user: t, api: a, setUser: r } = T(), [l, n] = i((t == null ? void 0 : t.name) ?? ""), [s, o] = i((t == null ? void 0 : t.email) ?? ""), [d, c] = i(!1), [u, b] = i(!1), [h, m] = i({
|
|
736
780
|
open: !1,
|
|
737
781
|
type: "success",
|
|
738
782
|
title: "",
|
|
739
783
|
message: ""
|
|
740
|
-
}),
|
|
741
|
-
|
|
742
|
-
if (!
|
|
784
|
+
}), k = "+971 50 827 8229";
|
|
785
|
+
W(() => {
|
|
786
|
+
if (!h.open)
|
|
743
787
|
return;
|
|
744
|
-
const
|
|
745
|
-
return () => window.clearTimeout(
|
|
746
|
-
}, [
|
|
747
|
-
let
|
|
748
|
-
async function
|
|
788
|
+
const f = window.setTimeout(() => m((E) => ({ ...E, open: !1 })), 3e3);
|
|
789
|
+
return () => window.clearTimeout(f);
|
|
790
|
+
}, [h.open]), W(() => {
|
|
791
|
+
let f = !1;
|
|
792
|
+
async function E() {
|
|
749
793
|
try {
|
|
750
|
-
const { data:
|
|
751
|
-
if (
|
|
794
|
+
const { data: p } = await a.get("/auth/client/me");
|
|
795
|
+
if (f)
|
|
752
796
|
return;
|
|
753
|
-
|
|
754
|
-
} catch (
|
|
755
|
-
console.error("Failed to load profile details:",
|
|
797
|
+
r(p), n((p == null ? void 0 : p.name) ?? ""), o((p == null ? void 0 : p.email) ?? "");
|
|
798
|
+
} catch (p) {
|
|
799
|
+
console.error("Failed to load profile details:", p);
|
|
756
800
|
}
|
|
757
801
|
}
|
|
758
|
-
return
|
|
759
|
-
|
|
802
|
+
return E(), () => {
|
|
803
|
+
f = !0;
|
|
760
804
|
};
|
|
761
|
-
}, [a,
|
|
762
|
-
const N =
|
|
805
|
+
}, [a, r]);
|
|
806
|
+
const N = J(() => (l || (t == null ? void 0 : t.name) || (t == null ? void 0 : t.email) || "").trim(), [l, t == null ? void 0 : t.name, t == null ? void 0 : t.email]), x = J(() => N.charAt(0).toUpperCase() || "?", [N]);
|
|
763
807
|
async function g() {
|
|
764
808
|
if (t) {
|
|
765
|
-
|
|
809
|
+
b(!0);
|
|
766
810
|
try {
|
|
767
|
-
await a.patch("/auth/client/me", { name:
|
|
811
|
+
await a.patch("/auth/client/me", { name: l }), r({ ...t, name: l }), c(!1), m({
|
|
768
812
|
open: !0,
|
|
769
813
|
type: "success",
|
|
770
814
|
title: "Changes saved",
|
|
771
815
|
message: "Your profile was updated successfully."
|
|
772
816
|
});
|
|
773
|
-
} catch (
|
|
774
|
-
console.error("Failed to update profile:",
|
|
817
|
+
} catch (f) {
|
|
818
|
+
console.error("Failed to update profile:", f), m({
|
|
775
819
|
open: !0,
|
|
776
820
|
type: "error",
|
|
777
821
|
title: "Save failed",
|
|
778
822
|
message: "Failed to save changes. Please try again."
|
|
779
823
|
});
|
|
780
824
|
} finally {
|
|
781
|
-
|
|
825
|
+
b(!1);
|
|
782
826
|
}
|
|
783
827
|
}
|
|
784
828
|
}
|
|
785
829
|
if (!t)
|
|
786
830
|
return /* @__PURE__ */ e.createElement("p", { className: "text-sm text-gray-500" }, "No user data available.");
|
|
787
|
-
const
|
|
788
|
-
return /* @__PURE__ */ e.createElement("div", { className: "max-w-3xl mx-auto" },
|
|
831
|
+
const v = h.type === "success";
|
|
832
|
+
return /* @__PURE__ */ e.createElement("div", { className: "max-w-3xl mx-auto" }, h.open && /* @__PURE__ */ e.createElement(
|
|
789
833
|
"div",
|
|
790
834
|
{
|
|
791
835
|
className: "fixed top-6 right-6 z-[999999] flex items-center gap-3 rounded-xl border bg-white px-4 py-3 shadow-lg",
|
|
792
836
|
role: "status",
|
|
793
837
|
"aria-live": "polite",
|
|
794
838
|
style: {
|
|
795
|
-
borderColor:
|
|
839
|
+
borderColor: v ? "#BBF7D0" : "#FECACA"
|
|
796
840
|
}
|
|
797
841
|
},
|
|
798
842
|
/* @__PURE__ */ e.createElement(
|
|
@@ -800,10 +844,10 @@ const Oe = () => {
|
|
|
800
844
|
{
|
|
801
845
|
className: "flex h-9 w-9 items-center justify-center rounded-full",
|
|
802
846
|
style: {
|
|
803
|
-
backgroundColor:
|
|
847
|
+
backgroundColor: v ? "#ECFDF5" : "#FEF2F2"
|
|
804
848
|
}
|
|
805
849
|
},
|
|
806
|
-
|
|
850
|
+
v ? /* @__PURE__ */ e.createElement(
|
|
807
851
|
"svg",
|
|
808
852
|
{
|
|
809
853
|
width: "18",
|
|
@@ -866,15 +910,15 @@ const Oe = () => {
|
|
|
866
910
|
"span",
|
|
867
911
|
{
|
|
868
912
|
className: "text-sm font-semibold",
|
|
869
|
-
style: { color:
|
|
913
|
+
style: { color: v ? "#15803D" : "#B91C1C" }
|
|
870
914
|
},
|
|
871
|
-
|
|
872
|
-
),
|
|
915
|
+
h.title
|
|
916
|
+
), h.message && /* @__PURE__ */ e.createElement("span", { className: "text-xs text-gray-500" }, h.message)),
|
|
873
917
|
/* @__PURE__ */ e.createElement(
|
|
874
918
|
"button",
|
|
875
919
|
{
|
|
876
920
|
type: "button",
|
|
877
|
-
onClick: () =>
|
|
921
|
+
onClick: () => m((f) => ({ ...f, open: !1 })),
|
|
878
922
|
className: "ml-2 rounded-md px-2 py-1 text-gray-500 hover:bg-gray-100",
|
|
879
923
|
"aria-label": "Close",
|
|
880
924
|
title: "Close"
|
|
@@ -908,7 +952,7 @@ const Oe = () => {
|
|
|
908
952
|
)
|
|
909
953
|
)
|
|
910
954
|
)
|
|
911
|
-
), /* @__PURE__ */ e.createElement("div", { className: "rounded-2xl border border-gray-200 bg-white shadow-sm" }, /* @__PURE__ */ e.createElement("div", { className: "px-6 pt-6 pb-4" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-4" }, /* @__PURE__ */ e.createElement("div", { className: "relative" }, /* @__PURE__ */ e.createElement("div", { className: "h-16 w-16 rounded-full bg-blue-600 flex items-center justify-center text-white text-2xl font-semibold" },
|
|
955
|
+
), /* @__PURE__ */ e.createElement("div", { className: "rounded-2xl border border-gray-200 bg-white shadow-sm" }, /* @__PURE__ */ e.createElement("div", { className: "px-6 pt-6 pb-4" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-4" }, /* @__PURE__ */ e.createElement("div", { className: "relative" }, /* @__PURE__ */ e.createElement("div", { className: "h-16 w-16 rounded-full bg-blue-600 flex items-center justify-center text-white text-2xl font-semibold" }, x), /* @__PURE__ */ e.createElement(
|
|
912
956
|
"button",
|
|
913
957
|
{
|
|
914
958
|
type: "button",
|
|
@@ -943,20 +987,20 @@ const Oe = () => {
|
|
|
943
987
|
}
|
|
944
988
|
)
|
|
945
989
|
)
|
|
946
|
-
)), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("h1", { className: "text-2xl font-semibold" }, "My Profile"), /* @__PURE__ */ e.createElement("p", { className: "text-sm text-gray-500" }, "Personal details"))),
|
|
990
|
+
)), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("h1", { className: "text-2xl font-semibold" }, "My Profile"), /* @__PURE__ */ e.createElement("p", { className: "text-sm text-gray-500" }, "Personal details"))), d ? /* @__PURE__ */ e.createElement(
|
|
947
991
|
"button",
|
|
948
992
|
{
|
|
949
993
|
type: "button",
|
|
950
994
|
onClick: g,
|
|
951
|
-
disabled:
|
|
995
|
+
disabled: u,
|
|
952
996
|
className: "rounded-full border border-blue-200 bg-blue-50 px-4 py-2 text-sm font-medium text-blue-700 hover:bg-blue-100 disabled:opacity-60"
|
|
953
997
|
},
|
|
954
|
-
|
|
998
|
+
u ? "Saving…" : "Save changes"
|
|
955
999
|
) : /* @__PURE__ */ e.createElement(
|
|
956
1000
|
"button",
|
|
957
1001
|
{
|
|
958
1002
|
type: "button",
|
|
959
|
-
onClick: () =>
|
|
1003
|
+
onClick: () => c(!0),
|
|
960
1004
|
title: "Edit profile",
|
|
961
1005
|
className: "h-9 w-9 rounded-full border border-gray-200 bg-white shadow-sm flex items-center justify-center hover:bg-gray-50"
|
|
962
1006
|
},
|
|
@@ -992,16 +1036,16 @@ const Oe = () => {
|
|
|
992
1036
|
"input",
|
|
993
1037
|
{
|
|
994
1038
|
type: "text",
|
|
995
|
-
value:
|
|
996
|
-
disabled: !
|
|
997
|
-
onChange: (
|
|
998
|
-
className: `w-full rounded-lg border px-3 py-2 text-sm outline-none ${
|
|
1039
|
+
value: l,
|
|
1040
|
+
disabled: !d || u,
|
|
1041
|
+
onChange: (f) => n(f.target.value),
|
|
1042
|
+
className: `w-full rounded-lg border px-3 py-2 text-sm outline-none ${d ? "border-gray-300 bg-white focus:border-blue-500 focus:ring-2 focus:ring-blue-100" : "border-gray-200 bg-gray-50 text-gray-700"}`
|
|
999
1043
|
}
|
|
1000
1044
|
)), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("label", { className: "block text-xs font-medium text-gray-500 mb-2" }, "Email ID"), /* @__PURE__ */ e.createElement(
|
|
1001
1045
|
"input",
|
|
1002
1046
|
{
|
|
1003
1047
|
type: "email",
|
|
1004
|
-
value:
|
|
1048
|
+
value: s,
|
|
1005
1049
|
disabled: !0,
|
|
1006
1050
|
className: "w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-700 cursor-not-allowed"
|
|
1007
1051
|
}
|
|
@@ -1009,17 +1053,17 @@ const Oe = () => {
|
|
|
1009
1053
|
"input",
|
|
1010
1054
|
{
|
|
1011
1055
|
type: "text",
|
|
1012
|
-
value:
|
|
1056
|
+
value: k,
|
|
1013
1057
|
disabled: !0,
|
|
1014
1058
|
className: "w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-700 cursor-not-allowed"
|
|
1015
1059
|
}
|
|
1016
|
-
))),
|
|
1060
|
+
))), d && /* @__PURE__ */ e.createElement(
|
|
1017
1061
|
"button",
|
|
1018
1062
|
{
|
|
1019
1063
|
type: "button",
|
|
1020
|
-
disabled:
|
|
1064
|
+
disabled: u,
|
|
1021
1065
|
onClick: () => {
|
|
1022
|
-
|
|
1066
|
+
c(!1), n((t == null ? void 0 : t.name) ?? "");
|
|
1023
1067
|
},
|
|
1024
1068
|
className: "mt-6 text-sm font-medium text-gray-600 hover:text-gray-900"
|
|
1025
1069
|
},
|
|
@@ -1028,13 +1072,13 @@ const Oe = () => {
|
|
|
1028
1072
|
};
|
|
1029
1073
|
export {
|
|
1030
1074
|
We as AuthProvider,
|
|
1031
|
-
|
|
1075
|
+
He as ProfilePage,
|
|
1032
1076
|
xe as RbacContext,
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1077
|
+
Ye as RbacProvider,
|
|
1078
|
+
Ge as RequirePermissions,
|
|
1079
|
+
T as useAuthState,
|
|
1080
|
+
ie as useCan,
|
|
1081
|
+
Oe as useGrant,
|
|
1038
1082
|
Ze as useHasModule,
|
|
1039
|
-
|
|
1083
|
+
pe as useHasRole
|
|
1040
1084
|
};
|