@thetechfossil/auth2 1.2.14 → 1.2.16
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/README.md +0 -0
- package/dist/index.components.d.mts +255 -0
- package/dist/index.components.d.ts +9 -1
- package/dist/index.components.js +215 -225
- package/dist/index.components.js.map +1 -1
- package/dist/index.components.mjs +103 -113
- package/dist/index.components.mjs.map +1 -1
- package/dist/index.d.mts +566 -0
- package/dist/index.d.ts +11 -33
- package/dist/index.js +263 -267
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -117
- package/dist/index.mjs.map +1 -1
- package/dist/index.next.d.mts +538 -0
- package/dist/index.next.d.ts +9 -1
- package/dist/index.next.js +277 -281
- package/dist/index.next.js.map +1 -1
- package/dist/index.next.mjs +113 -117
- package/dist/index.next.mjs.map +1 -1
- package/dist/index.next.server.d.mts +272 -0
- package/dist/index.next.server.d.ts +1 -1
- package/dist/index.next.server.js +12 -11
- package/dist/index.next.server.js.map +1 -1
- package/dist/index.next.server.mjs +12 -11
- package/dist/index.next.server.mjs.map +1 -1
- package/dist/index.node.d.mts +227 -0
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +8 -5
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +8 -5
- package/dist/index.node.mjs.map +1 -1
- package/next/index.js +0 -0
- package/next/index.mjs +0 -0
- package/next/package.json +0 -0
- package/next/server/package.json +0 -0
- package/next/server.js +0 -0
- package/next/server.mjs +0 -0
- package/package.json +21 -21
package/dist/index.components.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var React = require('react');
|
|
5
5
|
var axios = require('axios');
|
|
6
6
|
var upfiles = require('@thetechfossil/upfiles');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
|
|
9
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
12
12
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
13
13
|
|
|
14
14
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
15
15
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
16
16
|
}) : x)(function(x) {
|
|
17
|
-
if (typeof require !== "undefined")
|
|
18
|
-
|
|
19
|
-
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
17
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
18
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
20
19
|
});
|
|
21
20
|
var HttpClient = class {
|
|
22
21
|
constructor(baseUrl, defaultHeaders = {}) {
|
|
@@ -70,6 +69,11 @@ var HttpClient = class {
|
|
|
70
69
|
return Promise.reject(refreshError);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
72
|
+
if (error.response && error.response.data && error.response.data.message) {
|
|
73
|
+
const customError = new Error(error.response.data.message);
|
|
74
|
+
customError.response = error.response;
|
|
75
|
+
return Promise.reject(customError);
|
|
76
|
+
}
|
|
73
77
|
return Promise.reject(error);
|
|
74
78
|
}
|
|
75
79
|
);
|
|
@@ -189,8 +193,7 @@ var AuthService = class {
|
|
|
189
193
|
return this.token;
|
|
190
194
|
}
|
|
191
195
|
getCurrentUser() {
|
|
192
|
-
if (!this.token)
|
|
193
|
-
return null;
|
|
196
|
+
if (!this.token) return null;
|
|
194
197
|
try {
|
|
195
198
|
const payload = JSON.parse(atob(this.token.split(".")[1]));
|
|
196
199
|
return payload.user || null;
|
|
@@ -201,8 +204,7 @@ var AuthService = class {
|
|
|
201
204
|
}
|
|
202
205
|
// CSRF Token Management
|
|
203
206
|
async refreshCsrfToken() {
|
|
204
|
-
if (!this.config.csrfEnabled)
|
|
205
|
-
return;
|
|
207
|
+
if (!this.config.csrfEnabled) return;
|
|
206
208
|
try {
|
|
207
209
|
const response = await this.httpClient.get("/api/v1/auth/csrf-token");
|
|
208
210
|
if (response.csrfToken) {
|
|
@@ -511,11 +513,11 @@ var AuthService = class {
|
|
|
511
513
|
|
|
512
514
|
// src/react/use-auth.ts
|
|
513
515
|
var useAuth = (config) => {
|
|
514
|
-
const [authService] =
|
|
515
|
-
const [user, setUser] =
|
|
516
|
-
const [isAuthenticated, setIsAuthenticated] =
|
|
517
|
-
const [loading, setLoading] =
|
|
518
|
-
const checkAuthStatus =
|
|
516
|
+
const [authService] = React.useState(() => new AuthService(config));
|
|
517
|
+
const [user, setUser] = React.useState(null);
|
|
518
|
+
const [isAuthenticated, setIsAuthenticated] = React.useState(false);
|
|
519
|
+
const [loading, setLoading] = React.useState(true);
|
|
520
|
+
const checkAuthStatus = React.useCallback(() => {
|
|
519
521
|
const authenticated = authService.isAuthenticated();
|
|
520
522
|
setIsAuthenticated(authenticated);
|
|
521
523
|
if (authenticated) {
|
|
@@ -526,10 +528,10 @@ var useAuth = (config) => {
|
|
|
526
528
|
}
|
|
527
529
|
setLoading(false);
|
|
528
530
|
}, [authService]);
|
|
529
|
-
|
|
531
|
+
React.useEffect(() => {
|
|
530
532
|
checkAuthStatus();
|
|
531
533
|
}, [checkAuthStatus]);
|
|
532
|
-
const register =
|
|
534
|
+
const register = React.useCallback(async (data) => {
|
|
533
535
|
setLoading(true);
|
|
534
536
|
try {
|
|
535
537
|
const response = await authService.register(data);
|
|
@@ -538,7 +540,7 @@ var useAuth = (config) => {
|
|
|
538
540
|
setLoading(false);
|
|
539
541
|
}
|
|
540
542
|
}, [authService]);
|
|
541
|
-
const login =
|
|
543
|
+
const login = React.useCallback(async (data) => {
|
|
542
544
|
setLoading(true);
|
|
543
545
|
try {
|
|
544
546
|
const response = await authService.login(data);
|
|
@@ -551,7 +553,7 @@ var useAuth = (config) => {
|
|
|
551
553
|
setLoading(false);
|
|
552
554
|
}
|
|
553
555
|
}, [authService]);
|
|
554
|
-
const verify =
|
|
556
|
+
const verify = React.useCallback(async (data) => {
|
|
555
557
|
setLoading(true);
|
|
556
558
|
try {
|
|
557
559
|
const response = await authService.verify(data);
|
|
@@ -564,7 +566,7 @@ var useAuth = (config) => {
|
|
|
564
566
|
setLoading(false);
|
|
565
567
|
}
|
|
566
568
|
}, [authService]);
|
|
567
|
-
const verifyEmailToken =
|
|
569
|
+
const verifyEmailToken = React.useCallback(async (token) => {
|
|
568
570
|
setLoading(true);
|
|
569
571
|
try {
|
|
570
572
|
const response = await authService.verifyEmailToken(token);
|
|
@@ -577,7 +579,7 @@ var useAuth = (config) => {
|
|
|
577
579
|
setLoading(false);
|
|
578
580
|
}
|
|
579
581
|
}, [authService]);
|
|
580
|
-
const logout =
|
|
582
|
+
const logout = React.useCallback(async () => {
|
|
581
583
|
setLoading(true);
|
|
582
584
|
try {
|
|
583
585
|
await authService.logout();
|
|
@@ -587,7 +589,7 @@ var useAuth = (config) => {
|
|
|
587
589
|
setLoading(false);
|
|
588
590
|
}
|
|
589
591
|
}, [authService]);
|
|
590
|
-
const updateProfile =
|
|
592
|
+
const updateProfile = React.useCallback(async (data) => {
|
|
591
593
|
setLoading(true);
|
|
592
594
|
try {
|
|
593
595
|
const response = await authService.updateProfile(data);
|
|
@@ -599,7 +601,7 @@ var useAuth = (config) => {
|
|
|
599
601
|
setLoading(false);
|
|
600
602
|
}
|
|
601
603
|
}, [authService]);
|
|
602
|
-
const getProfile =
|
|
604
|
+
const getProfile = React.useCallback(async () => {
|
|
603
605
|
setLoading(true);
|
|
604
606
|
try {
|
|
605
607
|
const userData = await authService.getProfile();
|
|
@@ -609,7 +611,7 @@ var useAuth = (config) => {
|
|
|
609
611
|
setLoading(false);
|
|
610
612
|
}
|
|
611
613
|
}, [authService]);
|
|
612
|
-
const getAllUsers =
|
|
614
|
+
const getAllUsers = React.useCallback(async () => {
|
|
613
615
|
setLoading(true);
|
|
614
616
|
try {
|
|
615
617
|
return await authService.getAllUsers();
|
|
@@ -617,7 +619,7 @@ var useAuth = (config) => {
|
|
|
617
619
|
setLoading(false);
|
|
618
620
|
}
|
|
619
621
|
}, [authService]);
|
|
620
|
-
const getUserById =
|
|
622
|
+
const getUserById = React.useCallback(async (id) => {
|
|
621
623
|
setLoading(true);
|
|
622
624
|
try {
|
|
623
625
|
return await authService.getUserById(id);
|
|
@@ -625,7 +627,7 @@ var useAuth = (config) => {
|
|
|
625
627
|
setLoading(false);
|
|
626
628
|
}
|
|
627
629
|
}, [authService]);
|
|
628
|
-
const uploadAndUpdateAvatar =
|
|
630
|
+
const uploadAndUpdateAvatar = React.useCallback(async (file) => {
|
|
629
631
|
setLoading(true);
|
|
630
632
|
try {
|
|
631
633
|
const response = await authService.uploadAndUpdateAvatar(file);
|
|
@@ -653,9 +655,9 @@ var useAuth = (config) => {
|
|
|
653
655
|
uploadAndUpdateAvatar
|
|
654
656
|
};
|
|
655
657
|
};
|
|
656
|
-
var ThemeContext =
|
|
658
|
+
var ThemeContext = React__default.default.createContext({ theme: "light", mounted: false });
|
|
657
659
|
function useAuthTheme() {
|
|
658
|
-
return
|
|
660
|
+
return React.useContext(ThemeContext);
|
|
659
661
|
}
|
|
660
662
|
|
|
661
663
|
// src/react/hooks/useThemeColors.ts
|
|
@@ -707,7 +709,7 @@ try {
|
|
|
707
709
|
} catch (error) {
|
|
708
710
|
console.warn("react-phone-number-input not available, using fallback");
|
|
709
711
|
}
|
|
710
|
-
var CustomPhoneInput =
|
|
712
|
+
var CustomPhoneInput = React__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
711
713
|
"input",
|
|
712
714
|
{
|
|
713
715
|
...props,
|
|
@@ -726,8 +728,8 @@ var PhoneInput = ({
|
|
|
726
728
|
style = {}
|
|
727
729
|
}) => {
|
|
728
730
|
const colors = useThemeColors();
|
|
729
|
-
const [defaultCountry, setDefaultCountry] =
|
|
730
|
-
const styleContent =
|
|
731
|
+
const [defaultCountry, setDefaultCountry] = React.useState("US");
|
|
732
|
+
const styleContent = React.useMemo(() => `
|
|
731
733
|
.PhoneInput {
|
|
732
734
|
display: flex;
|
|
733
735
|
align-items: center;
|
|
@@ -839,7 +841,7 @@ var PhoneInput = ({
|
|
|
839
841
|
opacity: 0.6;
|
|
840
842
|
}
|
|
841
843
|
`, [colors]);
|
|
842
|
-
|
|
844
|
+
React.useEffect(() => {
|
|
843
845
|
const detectCountry = async () => {
|
|
844
846
|
try {
|
|
845
847
|
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
@@ -896,7 +898,7 @@ var PhoneInput = ({
|
|
|
896
898
|
};
|
|
897
899
|
detectCountry();
|
|
898
900
|
}, []);
|
|
899
|
-
const handleChange =
|
|
901
|
+
const handleChange = React.useMemo(() => (val) => {
|
|
900
902
|
onChange(val || "");
|
|
901
903
|
}, [onChange]);
|
|
902
904
|
if (!PhoneInputWithCountry) {
|
|
@@ -960,15 +962,15 @@ var LoginForm = ({
|
|
|
960
962
|
showOAuthButtons = true
|
|
961
963
|
}) => {
|
|
962
964
|
const colors = useThemeColors();
|
|
963
|
-
const [email, setEmail] =
|
|
964
|
-
const [phoneNumber, setPhoneNumber] =
|
|
965
|
-
const [usePhone, setUsePhone] =
|
|
966
|
-
const [password, setPassword] =
|
|
967
|
-
const [usePassword, setUsePassword] =
|
|
968
|
-
const [showPassword, setShowPassword] =
|
|
969
|
-
const [isLoading, setIsLoading] =
|
|
970
|
-
const [error, setError] =
|
|
971
|
-
const [rememberMe, setRememberMe] =
|
|
965
|
+
const [email, setEmail] = React.useState("");
|
|
966
|
+
const [phoneNumber, setPhoneNumber] = React.useState("");
|
|
967
|
+
const [usePhone, setUsePhone] = React.useState(false);
|
|
968
|
+
const [password, setPassword] = React.useState("");
|
|
969
|
+
const [usePassword, setUsePassword] = React.useState(false);
|
|
970
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
971
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
972
|
+
const [error, setError] = React.useState(null);
|
|
973
|
+
const [rememberMe, setRememberMe] = React.useState(false);
|
|
972
974
|
const { login } = useAuth({
|
|
973
975
|
baseUrl: config?.baseUrl || "http://localhost:7000"
|
|
974
976
|
});
|
|
@@ -1422,33 +1424,25 @@ var RegisterForm = ({
|
|
|
1422
1424
|
invitationToken
|
|
1423
1425
|
}) => {
|
|
1424
1426
|
const colors = useThemeColors();
|
|
1425
|
-
const [name, setName] =
|
|
1426
|
-
const [email, setEmail] =
|
|
1427
|
-
const [phoneNumber, setPhoneNumber] =
|
|
1428
|
-
const [password, setPassword] =
|
|
1429
|
-
const [confirmPassword, setConfirmPassword] =
|
|
1430
|
-
const [isLoading, setIsLoading] =
|
|
1431
|
-
const [error, setError] =
|
|
1432
|
-
|
|
1433
|
-
|
|
1427
|
+
const [name, setName] = React.useState("");
|
|
1428
|
+
const [email, setEmail] = React.useState("");
|
|
1429
|
+
const [phoneNumber, setPhoneNumber] = React.useState("");
|
|
1430
|
+
const [password, setPassword] = React.useState("");
|
|
1431
|
+
const [confirmPassword, setConfirmPassword] = React.useState("");
|
|
1432
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
1433
|
+
const [error, setError] = React.useState(null);
|
|
1434
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
1435
|
+
const [showConfirmPassword, setShowConfirmPassword] = React.useState(false);
|
|
1434
1436
|
const getPasswordStrength = (pwd) => {
|
|
1435
|
-
if (!pwd)
|
|
1436
|
-
return { strength: "weak", score: 0, label: "" };
|
|
1437
|
+
if (!pwd) return { strength: "weak", score: 0, label: "" };
|
|
1437
1438
|
let score = 0;
|
|
1438
|
-
if (pwd.length >= 6)
|
|
1439
|
-
|
|
1440
|
-
if (pwd
|
|
1441
|
-
|
|
1442
|
-
if (/[a-
|
|
1443
|
-
|
|
1444
|
-
if (
|
|
1445
|
-
score++;
|
|
1446
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
1447
|
-
score++;
|
|
1448
|
-
if (score <= 2)
|
|
1449
|
-
return { strength: "weak", score, label: "Weak" };
|
|
1450
|
-
if (score <= 3)
|
|
1451
|
-
return { strength: "medium", score, label: "Medium" };
|
|
1439
|
+
if (pwd.length >= 6) score++;
|
|
1440
|
+
if (pwd.length >= 8) score++;
|
|
1441
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
1442
|
+
if (/\d/.test(pwd)) score++;
|
|
1443
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
1444
|
+
if (score <= 2) return { strength: "weak", score, label: "Weak" };
|
|
1445
|
+
if (score <= 3) return { strength: "medium", score, label: "Medium" };
|
|
1452
1446
|
return { strength: "strong", score, label: "Strong" };
|
|
1453
1447
|
};
|
|
1454
1448
|
getPasswordStrength(password);
|
|
@@ -1500,10 +1494,8 @@ var RegisterForm = ({
|
|
|
1500
1494
|
password,
|
|
1501
1495
|
frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
|
|
1502
1496
|
};
|
|
1503
|
-
if (email)
|
|
1504
|
-
|
|
1505
|
-
if (phoneNumber)
|
|
1506
|
-
registerData.phoneNumber = phoneNumber;
|
|
1497
|
+
if (email) registerData.email = email;
|
|
1498
|
+
if (phoneNumber) registerData.phoneNumber = phoneNumber;
|
|
1507
1499
|
const response = await register(registerData);
|
|
1508
1500
|
if (response.success) {
|
|
1509
1501
|
onRegisterSuccess?.();
|
|
@@ -1896,11 +1888,11 @@ var OtpForm = ({
|
|
|
1896
1888
|
baseUrl
|
|
1897
1889
|
}) => {
|
|
1898
1890
|
const colors = useThemeColors();
|
|
1899
|
-
const [otp, setOtp] =
|
|
1900
|
-
const [isLoading, setIsLoading] =
|
|
1901
|
-
const [error, setError] =
|
|
1902
|
-
const [resendCooldown, setResendCooldown] =
|
|
1903
|
-
const [resendLoading, setResendLoading] =
|
|
1891
|
+
const [otp, setOtp] = React.useState("");
|
|
1892
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
1893
|
+
const [error, setError] = React.useState(null);
|
|
1894
|
+
const [resendCooldown, setResendCooldown] = React.useState(0);
|
|
1895
|
+
const [resendLoading, setResendLoading] = React.useState(false);
|
|
1904
1896
|
const { verify, login } = useAuth({
|
|
1905
1897
|
baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
|
|
1906
1898
|
});
|
|
@@ -1933,8 +1925,7 @@ var OtpForm = ({
|
|
|
1933
1925
|
}
|
|
1934
1926
|
};
|
|
1935
1927
|
const handleResendOtp = async () => {
|
|
1936
|
-
if (resendCooldown > 0 || resendLoading)
|
|
1937
|
-
return;
|
|
1928
|
+
if (resendCooldown > 0 || resendLoading) return;
|
|
1938
1929
|
setResendLoading(true);
|
|
1939
1930
|
setError(null);
|
|
1940
1931
|
try {
|
|
@@ -2112,9 +2103,9 @@ var AuthFlow = ({
|
|
|
2112
2103
|
initialStep = "login",
|
|
2113
2104
|
showTitle = true
|
|
2114
2105
|
}) => {
|
|
2115
|
-
const [step, setStep] =
|
|
2116
|
-
const [email, setEmail] =
|
|
2117
|
-
const [message, setMessage] =
|
|
2106
|
+
const [step, setStep] = React.useState(initialStep);
|
|
2107
|
+
const [email, setEmail] = React.useState("");
|
|
2108
|
+
const [message, setMessage] = React.useState(null);
|
|
2118
2109
|
const handleLoginSuccess = (email2, needsOtpVerification) => {
|
|
2119
2110
|
setEmail(email2);
|
|
2120
2111
|
if (needsOtpVerification) {
|
|
@@ -2249,13 +2240,13 @@ var EmailVerificationPage = ({
|
|
|
2249
2240
|
onVerificationError,
|
|
2250
2241
|
baseUrl
|
|
2251
2242
|
}) => {
|
|
2252
|
-
const [isLoading, setIsLoading] =
|
|
2253
|
-
const [message, setMessage] =
|
|
2254
|
-
const [isSuccess, setIsSuccess] =
|
|
2243
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
2244
|
+
const [message, setMessage] = React.useState("");
|
|
2245
|
+
const [isSuccess, setIsSuccess] = React.useState(false);
|
|
2255
2246
|
const { verifyEmailToken } = useAuth({
|
|
2256
2247
|
baseUrl: baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
|
|
2257
2248
|
});
|
|
2258
|
-
|
|
2249
|
+
React.useEffect(() => {
|
|
2259
2250
|
const verifyEmail = async () => {
|
|
2260
2251
|
if (!token) {
|
|
2261
2252
|
setIsLoading(false);
|
|
@@ -2360,15 +2351,15 @@ var EmailVerificationPage = ({
|
|
|
2360
2351
|
] })
|
|
2361
2352
|
] }) });
|
|
2362
2353
|
};
|
|
2363
|
-
var AuthContext =
|
|
2354
|
+
var AuthContext = React.createContext(void 0);
|
|
2364
2355
|
var useAuth2 = () => {
|
|
2365
|
-
const context =
|
|
2356
|
+
const context = React.useContext(AuthContext);
|
|
2366
2357
|
if (context === void 0) {
|
|
2367
2358
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
2368
2359
|
}
|
|
2369
2360
|
return context;
|
|
2370
2361
|
};
|
|
2371
|
-
var ThemeWrapper =
|
|
2362
|
+
var ThemeWrapper = React.forwardRef(
|
|
2372
2363
|
({ children, className = "", style }, ref) => {
|
|
2373
2364
|
const { theme, mounted } = useAuthTheme();
|
|
2374
2365
|
if (!mounted) {
|
|
@@ -2381,18 +2372,18 @@ ThemeWrapper.displayName = "ThemeWrapper";
|
|
|
2381
2372
|
var SignIn = ({ redirectUrl, appearance }) => {
|
|
2382
2373
|
const { signIn, isSignedIn, loading: authLoading } = useAuth2();
|
|
2383
2374
|
const colors = useThemeColors();
|
|
2384
|
-
const [email, setEmail] =
|
|
2385
|
-
const [phoneNumber, setPhoneNumber] =
|
|
2386
|
-
const [password, setPassword] =
|
|
2387
|
-
const [otp, setOtp] =
|
|
2388
|
-
const [usePassword, setUsePassword] =
|
|
2389
|
-
const [usePhone, setUsePhone] =
|
|
2390
|
-
const [showPassword, setShowPassword] =
|
|
2391
|
-
const [isLoading, setIsLoading] =
|
|
2392
|
-
const [error, setError] =
|
|
2393
|
-
const [needsOtp, setNeedsOtp] =
|
|
2394
|
-
const [success, setSuccess] =
|
|
2395
|
-
|
|
2375
|
+
const [email, setEmail] = React.useState("");
|
|
2376
|
+
const [phoneNumber, setPhoneNumber] = React.useState("");
|
|
2377
|
+
const [password, setPassword] = React.useState("");
|
|
2378
|
+
const [otp, setOtp] = React.useState("");
|
|
2379
|
+
const [usePassword, setUsePassword] = React.useState(false);
|
|
2380
|
+
const [usePhone, setUsePhone] = React.useState(false);
|
|
2381
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
2382
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
2383
|
+
const [error, setError] = React.useState(null);
|
|
2384
|
+
const [needsOtp, setNeedsOtp] = React.useState(false);
|
|
2385
|
+
const [success, setSuccess] = React.useState(null);
|
|
2386
|
+
React.useEffect(() => {
|
|
2396
2387
|
if (isSignedIn && redirectUrl) {
|
|
2397
2388
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
2398
2389
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -2783,16 +2774,16 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
2783
2774
|
var SignUp = ({ redirectUrl, appearance }) => {
|
|
2784
2775
|
const { signUp, isSignedIn } = useAuth2();
|
|
2785
2776
|
const colors = useThemeColors();
|
|
2786
|
-
const [name, setName] =
|
|
2787
|
-
const [email, setEmail] =
|
|
2788
|
-
const [phoneNumber, setPhoneNumber] =
|
|
2789
|
-
const [password, setPassword] =
|
|
2790
|
-
const [confirmPassword, setConfirmPassword] =
|
|
2791
|
-
const [showPassword, setShowPassword] =
|
|
2792
|
-
const [isLoading, setIsLoading] =
|
|
2793
|
-
const [error, setError] =
|
|
2794
|
-
const [success, setSuccess] =
|
|
2795
|
-
|
|
2777
|
+
const [name, setName] = React.useState("");
|
|
2778
|
+
const [email, setEmail] = React.useState("");
|
|
2779
|
+
const [phoneNumber, setPhoneNumber] = React.useState("");
|
|
2780
|
+
const [password, setPassword] = React.useState("");
|
|
2781
|
+
const [confirmPassword, setConfirmPassword] = React.useState("");
|
|
2782
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
2783
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
2784
|
+
const [error, setError] = React.useState(null);
|
|
2785
|
+
const [success, setSuccess] = React.useState(null);
|
|
2786
|
+
React.useEffect(() => {
|
|
2796
2787
|
if (isSignedIn && redirectUrl) {
|
|
2797
2788
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
|
|
2798
2789
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -2800,23 +2791,15 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2800
2791
|
}
|
|
2801
2792
|
}, [isSignedIn, redirectUrl]);
|
|
2802
2793
|
const getPasswordStrength = (pwd, colors2) => {
|
|
2803
|
-
if (!pwd)
|
|
2804
|
-
return { strength: "weak", color: colors2.borderSecondary };
|
|
2794
|
+
if (!pwd) return { strength: "weak", color: colors2.borderSecondary };
|
|
2805
2795
|
let score = 0;
|
|
2806
|
-
if (pwd.length >= 6)
|
|
2807
|
-
|
|
2808
|
-
if (pwd
|
|
2809
|
-
|
|
2810
|
-
if (/[a-
|
|
2811
|
-
|
|
2812
|
-
if (
|
|
2813
|
-
score++;
|
|
2814
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
2815
|
-
score++;
|
|
2816
|
-
if (score <= 2)
|
|
2817
|
-
return { strength: "weak", color: colors2.errorText };
|
|
2818
|
-
if (score <= 3)
|
|
2819
|
-
return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
2796
|
+
if (pwd.length >= 6) score++;
|
|
2797
|
+
if (pwd.length >= 8) score++;
|
|
2798
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
2799
|
+
if (/\d/.test(pwd)) score++;
|
|
2800
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
2801
|
+
if (score <= 2) return { strength: "weak", color: colors2.errorText };
|
|
2802
|
+
if (score <= 3) return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
2820
2803
|
return { strength: "strong", color: colors2.successText };
|
|
2821
2804
|
};
|
|
2822
2805
|
const passwordStrength = getPasswordStrength(password, colors);
|
|
@@ -2837,10 +2820,8 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2837
2820
|
}
|
|
2838
2821
|
try {
|
|
2839
2822
|
const signUpData = { name, password };
|
|
2840
|
-
if (email)
|
|
2841
|
-
|
|
2842
|
-
if (phoneNumber)
|
|
2843
|
-
signUpData.phoneNumber = phoneNumber;
|
|
2823
|
+
if (email) signUpData.email = email;
|
|
2824
|
+
if (phoneNumber) signUpData.phoneNumber = phoneNumber;
|
|
2844
2825
|
const response = await signUp(signUpData);
|
|
2845
2826
|
if (response.success) {
|
|
2846
2827
|
setSuccess("Registration successful! Please check your email to verify your account.");
|
|
@@ -3156,7 +3137,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
3156
3137
|
};
|
|
3157
3138
|
var SignOut = ({ redirectUrl }) => {
|
|
3158
3139
|
const { signOut } = useAuth2();
|
|
3159
|
-
|
|
3140
|
+
React.useEffect(() => {
|
|
3160
3141
|
const performSignOut = async () => {
|
|
3161
3142
|
await signOut();
|
|
3162
3143
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
|
|
@@ -3170,9 +3151,9 @@ var SignOut = ({ redirectUrl }) => {
|
|
|
3170
3151
|
var UserButton = ({ showName = false, appearance }) => {
|
|
3171
3152
|
const { user, signOut } = useAuth2();
|
|
3172
3153
|
const colors = useThemeColors();
|
|
3173
|
-
const [isOpen, setIsOpen] =
|
|
3174
|
-
const dropdownRef =
|
|
3175
|
-
|
|
3154
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
3155
|
+
const dropdownRef = React.useRef(null);
|
|
3156
|
+
React.useEffect(() => {
|
|
3176
3157
|
const handleClickOutside = (event) => {
|
|
3177
3158
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
3178
3159
|
setIsOpen(false);
|
|
@@ -3181,8 +3162,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3181
3162
|
document.addEventListener("mousedown", handleClickOutside);
|
|
3182
3163
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
3183
3164
|
}, []);
|
|
3184
|
-
if (!user)
|
|
3185
|
-
return null;
|
|
3165
|
+
if (!user) return null;
|
|
3186
3166
|
const getInitials = (name) => {
|
|
3187
3167
|
return name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
|
|
3188
3168
|
};
|
|
@@ -3216,7 +3196,19 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3216
3196
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
3217
3197
|
},
|
|
3218
3198
|
children: [
|
|
3219
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3199
|
+
user.avatar ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3200
|
+
"img",
|
|
3201
|
+
{
|
|
3202
|
+
src: user.avatar,
|
|
3203
|
+
alt: user.name,
|
|
3204
|
+
style: {
|
|
3205
|
+
width: "36px",
|
|
3206
|
+
height: "36px",
|
|
3207
|
+
borderRadius: "50%",
|
|
3208
|
+
objectFit: "cover"
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
3220
3212
|
width: "36px",
|
|
3221
3213
|
height: "36px",
|
|
3222
3214
|
borderRadius: "50%",
|
|
@@ -3253,7 +3245,19 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3253
3245
|
alignItems: "center",
|
|
3254
3246
|
gap: "12px"
|
|
3255
3247
|
}, children: [
|
|
3256
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3248
|
+
user.avatar ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3249
|
+
"img",
|
|
3250
|
+
{
|
|
3251
|
+
src: user.avatar,
|
|
3252
|
+
alt: user.name,
|
|
3253
|
+
style: {
|
|
3254
|
+
width: "48px",
|
|
3255
|
+
height: "48px",
|
|
3256
|
+
borderRadius: "50%",
|
|
3257
|
+
objectFit: "cover"
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
3257
3261
|
width: "48px",
|
|
3258
3262
|
height: "48px",
|
|
3259
3263
|
borderRadius: "50%",
|
|
@@ -3318,7 +3322,7 @@ var ProtectedRoute = ({
|
|
|
3318
3322
|
redirectTo
|
|
3319
3323
|
}) => {
|
|
3320
3324
|
const { isSignedIn, isLoaded } = useAuth2();
|
|
3321
|
-
|
|
3325
|
+
React.useEffect(() => {
|
|
3322
3326
|
if (isLoaded && !isSignedIn) {
|
|
3323
3327
|
const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
|
|
3324
3328
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -3343,7 +3347,7 @@ var PublicRoute = ({
|
|
|
3343
3347
|
redirectTo
|
|
3344
3348
|
}) => {
|
|
3345
3349
|
const { isSignedIn, isLoaded } = useAuth2();
|
|
3346
|
-
|
|
3350
|
+
React.useEffect(() => {
|
|
3347
3351
|
if (isLoaded && isSignedIn) {
|
|
3348
3352
|
const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
3349
3353
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -3365,9 +3369,9 @@ var PublicRoute = ({
|
|
|
3365
3369
|
};
|
|
3366
3370
|
var VerifyEmail = ({ token, onSuccess, onError }) => {
|
|
3367
3371
|
const { verifyEmailToken } = useAuth2();
|
|
3368
|
-
const [status, setStatus] =
|
|
3369
|
-
const [message, setMessage] =
|
|
3370
|
-
|
|
3372
|
+
const [status, setStatus] = React.useState("loading");
|
|
3373
|
+
const [message, setMessage] = React.useState("");
|
|
3374
|
+
React.useEffect(() => {
|
|
3371
3375
|
const verify = async () => {
|
|
3372
3376
|
const verifyToken = token || (typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("token") : null);
|
|
3373
3377
|
if (!verifyToken) {
|
|
@@ -3501,10 +3505,10 @@ var VerifyEmail = ({ token, onSuccess, onError }) => {
|
|
|
3501
3505
|
};
|
|
3502
3506
|
var ForgotPassword = ({ appearance }) => {
|
|
3503
3507
|
const { forgotPassword } = useAuth2();
|
|
3504
|
-
const [email, setEmail] =
|
|
3505
|
-
const [isLoading, setIsLoading] =
|
|
3506
|
-
const [error, setError] =
|
|
3507
|
-
const [success, setSuccess] =
|
|
3508
|
+
const [email, setEmail] = React.useState("");
|
|
3509
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
3510
|
+
const [error, setError] = React.useState(null);
|
|
3511
|
+
const [success, setSuccess] = React.useState(null);
|
|
3508
3512
|
const handleSubmit = async (e) => {
|
|
3509
3513
|
e.preventDefault();
|
|
3510
3514
|
setIsLoading(true);
|
|
@@ -3643,14 +3647,14 @@ var ForgotPassword = ({ appearance }) => {
|
|
|
3643
3647
|
};
|
|
3644
3648
|
var ResetPassword = ({ token, appearance }) => {
|
|
3645
3649
|
const { resetPassword } = useAuth2();
|
|
3646
|
-
const [resetToken, setResetToken] =
|
|
3647
|
-
const [password, setPassword] =
|
|
3648
|
-
const [confirmPassword, setConfirmPassword] =
|
|
3649
|
-
const [showPassword, setShowPassword] =
|
|
3650
|
-
const [isLoading, setIsLoading] =
|
|
3651
|
-
const [error, setError] =
|
|
3652
|
-
const [success, setSuccess] =
|
|
3653
|
-
|
|
3650
|
+
const [resetToken, setResetToken] = React.useState(token || "");
|
|
3651
|
+
const [password, setPassword] = React.useState("");
|
|
3652
|
+
const [confirmPassword, setConfirmPassword] = React.useState("");
|
|
3653
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
3654
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
3655
|
+
const [error, setError] = React.useState(null);
|
|
3656
|
+
const [success, setSuccess] = React.useState(false);
|
|
3657
|
+
React.useEffect(() => {
|
|
3654
3658
|
if (!resetToken && typeof window !== "undefined") {
|
|
3655
3659
|
const urlToken = new URLSearchParams(window.location.search).get("token");
|
|
3656
3660
|
if (urlToken) {
|
|
@@ -3659,23 +3663,15 @@ var ResetPassword = ({ token, appearance }) => {
|
|
|
3659
3663
|
}
|
|
3660
3664
|
}, [resetToken]);
|
|
3661
3665
|
const getPasswordStrength = (pwd) => {
|
|
3662
|
-
if (!pwd)
|
|
3663
|
-
return { strength: "weak", color: "#ddd" };
|
|
3666
|
+
if (!pwd) return { strength: "weak", color: "#ddd" };
|
|
3664
3667
|
let score = 0;
|
|
3665
|
-
if (pwd.length >= 6)
|
|
3666
|
-
|
|
3667
|
-
if (pwd
|
|
3668
|
-
|
|
3669
|
-
if (/[a-
|
|
3670
|
-
|
|
3671
|
-
if (
|
|
3672
|
-
score++;
|
|
3673
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
3674
|
-
score++;
|
|
3675
|
-
if (score <= 2)
|
|
3676
|
-
return { strength: "weak", color: "#f44" };
|
|
3677
|
-
if (score <= 3)
|
|
3678
|
-
return { strength: "medium", color: "#fa4" };
|
|
3668
|
+
if (pwd.length >= 6) score++;
|
|
3669
|
+
if (pwd.length >= 8) score++;
|
|
3670
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
3671
|
+
if (/\d/.test(pwd)) score++;
|
|
3672
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
3673
|
+
if (score <= 2) return { strength: "weak", color: "#f44" };
|
|
3674
|
+
if (score <= 3) return { strength: "medium", color: "#fa4" };
|
|
3679
3675
|
return { strength: "strong", color: "#4f4" };
|
|
3680
3676
|
};
|
|
3681
3677
|
const passwordStrength = getPasswordStrength(password);
|
|
@@ -3905,31 +3901,23 @@ var ResetPassword = ({ token, appearance }) => {
|
|
|
3905
3901
|
};
|
|
3906
3902
|
var ChangePassword = ({ onSuccess, appearance }) => {
|
|
3907
3903
|
const { changePassword } = useAuth2();
|
|
3908
|
-
const [oldPassword, setOldPassword] =
|
|
3909
|
-
const [newPassword, setNewPassword] =
|
|
3910
|
-
const [confirmPassword, setConfirmPassword] =
|
|
3911
|
-
const [showPasswords, setShowPasswords] =
|
|
3912
|
-
const [isLoading, setIsLoading] =
|
|
3913
|
-
const [error, setError] =
|
|
3914
|
-
const [success, setSuccess] =
|
|
3904
|
+
const [oldPassword, setOldPassword] = React.useState("");
|
|
3905
|
+
const [newPassword, setNewPassword] = React.useState("");
|
|
3906
|
+
const [confirmPassword, setConfirmPassword] = React.useState("");
|
|
3907
|
+
const [showPasswords, setShowPasswords] = React.useState(false);
|
|
3908
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
3909
|
+
const [error, setError] = React.useState(null);
|
|
3910
|
+
const [success, setSuccess] = React.useState(false);
|
|
3915
3911
|
const getPasswordStrength = (pwd) => {
|
|
3916
|
-
if (!pwd)
|
|
3917
|
-
return { strength: "weak", color: "#ddd" };
|
|
3912
|
+
if (!pwd) return { strength: "weak", color: "#ddd" };
|
|
3918
3913
|
let score = 0;
|
|
3919
|
-
if (pwd.length >= 6)
|
|
3920
|
-
|
|
3921
|
-
if (pwd
|
|
3922
|
-
|
|
3923
|
-
if (/[a-
|
|
3924
|
-
|
|
3925
|
-
if (
|
|
3926
|
-
score++;
|
|
3927
|
-
if (/[^a-zA-Z\d]/.test(pwd))
|
|
3928
|
-
score++;
|
|
3929
|
-
if (score <= 2)
|
|
3930
|
-
return { strength: "weak", color: "#f44" };
|
|
3931
|
-
if (score <= 3)
|
|
3932
|
-
return { strength: "medium", color: "#fa4" };
|
|
3914
|
+
if (pwd.length >= 6) score++;
|
|
3915
|
+
if (pwd.length >= 8) score++;
|
|
3916
|
+
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score++;
|
|
3917
|
+
if (/\d/.test(pwd)) score++;
|
|
3918
|
+
if (/[^a-zA-Z\d]/.test(pwd)) score++;
|
|
3919
|
+
if (score <= 2) return { strength: "weak", color: "#f44" };
|
|
3920
|
+
if (score <= 3) return { strength: "medium", color: "#fa4" };
|
|
3933
3921
|
return { strength: "strong", color: "#4f4" };
|
|
3934
3922
|
};
|
|
3935
3923
|
const passwordStrength = getPasswordStrength(newPassword);
|
|
@@ -4160,31 +4148,21 @@ var AvatarUploader = ({
|
|
|
4160
4148
|
buttonText = "Upload Avatar"
|
|
4161
4149
|
}) => {
|
|
4162
4150
|
const { uploadAndUpdateAvatar } = useAuth2();
|
|
4163
|
-
const [open, setOpen] =
|
|
4164
|
-
const [uploading, setUploading] =
|
|
4151
|
+
const [open, setOpen] = React.useState(false);
|
|
4152
|
+
const [uploading, setUploading] = React.useState(false);
|
|
4165
4153
|
const handleSelect = async (image) => {
|
|
4166
4154
|
setUploading(true);
|
|
4167
4155
|
try {
|
|
4168
|
-
const
|
|
4169
|
-
const response = await
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
} : {}
|
|
4173
|
-
});
|
|
4174
|
-
if (!response.ok) {
|
|
4175
|
-
throw new Error("Failed to fetch image");
|
|
4176
|
-
}
|
|
4177
|
-
const blob = await response.blob();
|
|
4178
|
-
const file = new File([blob], image.originalName, { type: image.contentType });
|
|
4179
|
-
const result = await uploadAndUpdateAvatar(file);
|
|
4180
|
-
if (result.success && result.user?.avatar) {
|
|
4181
|
-
onUploadComplete?.(result.user.avatar);
|
|
4156
|
+
const { updateProfile } = useAuth2();
|
|
4157
|
+
const response = await updateProfile({ avatar: image.url });
|
|
4158
|
+
if (response.success && response.user?.avatar) {
|
|
4159
|
+
onUploadComplete?.(response.user.avatar);
|
|
4182
4160
|
setOpen(false);
|
|
4183
4161
|
} else {
|
|
4184
|
-
throw new Error(
|
|
4162
|
+
throw new Error(response.message || "Failed to update avatar");
|
|
4185
4163
|
}
|
|
4186
4164
|
} catch (error) {
|
|
4187
|
-
const err = error instanceof Error ? error : new Error("
|
|
4165
|
+
const err = error instanceof Error ? error : new Error("Failed to update avatar");
|
|
4188
4166
|
onError?.(err);
|
|
4189
4167
|
} finally {
|
|
4190
4168
|
setUploading(false);
|
|
@@ -4235,12 +4213,12 @@ var UserProfile = ({
|
|
|
4235
4213
|
}) => {
|
|
4236
4214
|
const { user, updateProfile, requestEmailChange } = useAuth2();
|
|
4237
4215
|
const colors = useThemeColors();
|
|
4238
|
-
const [name, setName] =
|
|
4239
|
-
const [phoneNumber, setPhoneNumber] =
|
|
4240
|
-
const [newEmail, setNewEmail] =
|
|
4241
|
-
const [isLoading, setIsLoading] =
|
|
4242
|
-
const [error, setError] =
|
|
4243
|
-
const [success, setSuccess] =
|
|
4216
|
+
const [name, setName] = React.useState(user?.name || "");
|
|
4217
|
+
const [phoneNumber, setPhoneNumber] = React.useState(user?.phoneNumber || "");
|
|
4218
|
+
const [newEmail, setNewEmail] = React.useState("");
|
|
4219
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
4220
|
+
const [error, setError] = React.useState(null);
|
|
4221
|
+
const [success, setSuccess] = React.useState(null);
|
|
4244
4222
|
const handleUpdateProfile = async (e) => {
|
|
4245
4223
|
e.preventDefault();
|
|
4246
4224
|
setIsLoading(true);
|
|
@@ -4297,8 +4275,7 @@ var UserProfile = ({
|
|
|
4297
4275
|
setIsLoading(false);
|
|
4298
4276
|
}
|
|
4299
4277
|
};
|
|
4300
|
-
if (!user)
|
|
4301
|
-
return null;
|
|
4278
|
+
if (!user) return null;
|
|
4302
4279
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
|
|
4303
4280
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
|
|
4304
4281
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
@@ -4532,12 +4509,18 @@ var AvatarManager = ({
|
|
|
4532
4509
|
gridClassName,
|
|
4533
4510
|
maxFileSize = 5 * 1024 * 1024,
|
|
4534
4511
|
// 5MB default
|
|
4512
|
+
maxFiles = 10,
|
|
4535
4513
|
mode = "full",
|
|
4536
4514
|
showDelete = false,
|
|
4515
|
+
autoRecordToDb = true,
|
|
4516
|
+
fetchThumbnails = true,
|
|
4517
|
+
projectId,
|
|
4518
|
+
deleteUrl,
|
|
4519
|
+
onDelete,
|
|
4537
4520
|
upfilesConfig
|
|
4538
4521
|
}) => {
|
|
4539
4522
|
const { updateProfile } = useAuth2();
|
|
4540
|
-
const [updating, setUpdating] =
|
|
4523
|
+
const [updating, setUpdating] = React.useState(false);
|
|
4541
4524
|
const handleSelect = async (image) => {
|
|
4542
4525
|
setUpdating(true);
|
|
4543
4526
|
try {
|
|
@@ -4565,18 +4548,25 @@ var AvatarManager = ({
|
|
|
4565
4548
|
apiKey: upfilesConfig.apiKey,
|
|
4566
4549
|
apiKeyHeader: upfilesConfig.apiKeyHeader || "authorization",
|
|
4567
4550
|
presignUrl: upfilesConfig.presignUrl,
|
|
4568
|
-
presignPath: upfilesConfig.presignPath
|
|
4551
|
+
presignPath: upfilesConfig.presignPath,
|
|
4552
|
+
headers: upfilesConfig.headers,
|
|
4553
|
+
withCredentials: upfilesConfig.withCredentials
|
|
4569
4554
|
},
|
|
4570
|
-
|
|
4555
|
+
projectId,
|
|
4556
|
+
folderPath: upfilesConfig.folderPath || "/",
|
|
4571
4557
|
title,
|
|
4572
4558
|
description,
|
|
4573
4559
|
className,
|
|
4574
4560
|
gridClassName,
|
|
4575
4561
|
onSelect: handleSelect,
|
|
4562
|
+
onDelete,
|
|
4563
|
+
deleteUrl,
|
|
4564
|
+
autoRecordToDb,
|
|
4565
|
+
fetchThumbnails,
|
|
4576
4566
|
maxFileSize,
|
|
4567
|
+
maxFiles,
|
|
4577
4568
|
mode,
|
|
4578
|
-
showDelete
|
|
4579
|
-
fetchThumbnails: true
|
|
4569
|
+
showDelete
|
|
4580
4570
|
}
|
|
4581
4571
|
);
|
|
4582
4572
|
};
|
|
@@ -4600,5 +4590,5 @@ exports.SignUp = SignUp;
|
|
|
4600
4590
|
exports.UserButton = UserButton;
|
|
4601
4591
|
exports.UserProfile = UserProfile;
|
|
4602
4592
|
exports.VerifyEmail = VerifyEmail;
|
|
4603
|
-
//# sourceMappingURL=
|
|
4593
|
+
//# sourceMappingURL=index.components.js.map
|
|
4604
4594
|
//# sourceMappingURL=index.components.js.map
|