@thetechfossil/auth2 1.2.3 → 1.2.5
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/index.components.d.ts +14 -1
- package/dist/index.components.js +1284 -638
- package/dist/index.components.js.map +1 -1
- package/dist/index.components.mjs +1186 -543
- package/dist/index.components.mjs.map +1 -1
- package/dist/index.d.ts +48 -5
- package/dist/index.js +1364 -669
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1237 -544
- package/dist/index.mjs.map +1 -1
- package/dist/index.next.d.ts +41 -6
- package/dist/index.next.js +1382 -687
- package/dist/index.next.js.map +1 -1
- package/dist/index.next.mjs +1234 -544
- package/dist/index.next.mjs.map +1 -1
- package/dist/index.next.server.d.ts +16 -5
- package/dist/index.next.server.js +16 -9
- package/dist/index.next.server.js.map +1 -1
- package/dist/index.next.server.mjs +16 -9
- package/dist/index.next.server.mjs.map +1 -1
- package/dist/index.node.d.ts +16 -5
- package/dist/index.node.js +15 -9
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +15 -9
- package/dist/index.node.mjs.map +1 -1
- package/package.json +90 -87
- package/README.NEW.md +0 -365
package/dist/index.next.js
CHANGED
|
@@ -2,20 +2,25 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var axios = require('axios');
|
|
5
|
-
var
|
|
5
|
+
var React3 = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var PhoneInputWithCountry = require('react-phone-number-input');
|
|
8
|
+
require('react-phone-number-input/style.css');
|
|
7
9
|
|
|
8
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
11
|
|
|
10
12
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
13
|
+
var React3__default = /*#__PURE__*/_interopDefault(React3);
|
|
14
|
+
var PhoneInputWithCountry__default = /*#__PURE__*/_interopDefault(PhoneInputWithCountry);
|
|
11
15
|
|
|
12
16
|
// src/core/http-client.ts
|
|
13
17
|
var HttpClient = class {
|
|
14
18
|
constructor(baseUrl, defaultHeaders = {}) {
|
|
15
19
|
this.csrfToken = null;
|
|
16
20
|
this.frontendBaseUrl = null;
|
|
21
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
17
22
|
this.axiosInstance = axios__default.default.create({
|
|
18
|
-
baseURL: baseUrl
|
|
23
|
+
baseURL: this.baseUrl,
|
|
19
24
|
headers: {
|
|
20
25
|
"Content-Type": "application/json",
|
|
21
26
|
...defaultHeaders
|
|
@@ -26,8 +31,16 @@ var HttpClient = class {
|
|
|
26
31
|
// 30 second timeout
|
|
27
32
|
});
|
|
28
33
|
this.axiosInstance.interceptors.request.use(
|
|
29
|
-
(config) => {
|
|
30
|
-
|
|
34
|
+
async (config) => {
|
|
35
|
+
const isMutatingRequest = ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "");
|
|
36
|
+
if (isMutatingRequest && !this.csrfToken && typeof window !== "undefined") {
|
|
37
|
+
try {
|
|
38
|
+
await this.refreshCsrfToken();
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.warn("Failed to fetch CSRF token:", error);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (this.csrfToken && isMutatingRequest) {
|
|
31
44
|
config.headers["x-csrf-token"] = this.csrfToken;
|
|
32
45
|
}
|
|
33
46
|
if (this.frontendBaseUrl) {
|
|
@@ -125,9 +138,6 @@ var AuthService = class {
|
|
|
125
138
|
this.httpClient.setFrontendBaseUrl(frontendBaseUrl);
|
|
126
139
|
}
|
|
127
140
|
}
|
|
128
|
-
if (this.config.csrfEnabled && typeof window !== "undefined") {
|
|
129
|
-
this.refreshCsrfToken();
|
|
130
|
-
}
|
|
131
141
|
}
|
|
132
142
|
loadTokenFromStorage() {
|
|
133
143
|
if (typeof window !== "undefined" && this.config.localStorageKey) {
|
|
@@ -229,7 +239,7 @@ var AuthService = class {
|
|
|
229
239
|
this.saveTokenToStorage(response.token);
|
|
230
240
|
return response;
|
|
231
241
|
}
|
|
232
|
-
if (response.success && response.message === "OTP sent to your email.") {
|
|
242
|
+
if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
|
|
233
243
|
return response;
|
|
234
244
|
}
|
|
235
245
|
if (response.success && response.message === "OTP verified successfully." && response.token) {
|
|
@@ -300,7 +310,7 @@ var AuthService = class {
|
|
|
300
310
|
if (!this.token) {
|
|
301
311
|
throw new Error("Not authenticated");
|
|
302
312
|
}
|
|
303
|
-
const response = await this.httpClient.post("/api/v1/user/update/
|
|
313
|
+
const response = await this.httpClient.post("/api/v1/user/update/profile", data);
|
|
304
314
|
if (response.success && response.token) {
|
|
305
315
|
this.token = response.token;
|
|
306
316
|
this.httpClient.setAuthToken(response.token);
|
|
@@ -341,7 +351,7 @@ var AuthService = class {
|
|
|
341
351
|
if (!this.token) {
|
|
342
352
|
throw new Error("Not authenticated");
|
|
343
353
|
}
|
|
344
|
-
const response = await this.httpClient.post("/api/v1/user/update/
|
|
354
|
+
const response = await this.httpClient.post("/api/v1/user/update/profile", { avatar });
|
|
345
355
|
if (response.success && response.token) {
|
|
346
356
|
this.token = response.token;
|
|
347
357
|
this.httpClient.setAuthToken(response.token);
|
|
@@ -465,11 +475,11 @@ var AuthService = class {
|
|
|
465
475
|
}
|
|
466
476
|
};
|
|
467
477
|
var useAuth = (config) => {
|
|
468
|
-
const [authService] =
|
|
469
|
-
const [user, setUser] =
|
|
470
|
-
const [isAuthenticated, setIsAuthenticated] =
|
|
471
|
-
const [loading, setLoading] =
|
|
472
|
-
const checkAuthStatus =
|
|
478
|
+
const [authService] = React3.useState(() => new AuthService(config));
|
|
479
|
+
const [user, setUser] = React3.useState(null);
|
|
480
|
+
const [isAuthenticated, setIsAuthenticated] = React3.useState(false);
|
|
481
|
+
const [loading, setLoading] = React3.useState(true);
|
|
482
|
+
const checkAuthStatus = React3.useCallback(() => {
|
|
473
483
|
const authenticated = authService.isAuthenticated();
|
|
474
484
|
setIsAuthenticated(authenticated);
|
|
475
485
|
if (authenticated) {
|
|
@@ -480,10 +490,10 @@ var useAuth = (config) => {
|
|
|
480
490
|
}
|
|
481
491
|
setLoading(false);
|
|
482
492
|
}, [authService]);
|
|
483
|
-
|
|
493
|
+
React3.useEffect(() => {
|
|
484
494
|
checkAuthStatus();
|
|
485
495
|
}, [checkAuthStatus]);
|
|
486
|
-
const register =
|
|
496
|
+
const register = React3.useCallback(async (data) => {
|
|
487
497
|
setLoading(true);
|
|
488
498
|
try {
|
|
489
499
|
const response = await authService.register(data);
|
|
@@ -492,7 +502,7 @@ var useAuth = (config) => {
|
|
|
492
502
|
setLoading(false);
|
|
493
503
|
}
|
|
494
504
|
}, [authService]);
|
|
495
|
-
const login =
|
|
505
|
+
const login = React3.useCallback(async (data) => {
|
|
496
506
|
setLoading(true);
|
|
497
507
|
try {
|
|
498
508
|
const response = await authService.login(data);
|
|
@@ -505,7 +515,7 @@ var useAuth = (config) => {
|
|
|
505
515
|
setLoading(false);
|
|
506
516
|
}
|
|
507
517
|
}, [authService]);
|
|
508
|
-
const verify =
|
|
518
|
+
const verify = React3.useCallback(async (data) => {
|
|
509
519
|
setLoading(true);
|
|
510
520
|
try {
|
|
511
521
|
const response = await authService.verify(data);
|
|
@@ -518,7 +528,7 @@ var useAuth = (config) => {
|
|
|
518
528
|
setLoading(false);
|
|
519
529
|
}
|
|
520
530
|
}, [authService]);
|
|
521
|
-
const verifyEmailToken =
|
|
531
|
+
const verifyEmailToken = React3.useCallback(async (token) => {
|
|
522
532
|
setLoading(true);
|
|
523
533
|
try {
|
|
524
534
|
const response = await authService.verifyEmailToken(token);
|
|
@@ -531,7 +541,7 @@ var useAuth = (config) => {
|
|
|
531
541
|
setLoading(false);
|
|
532
542
|
}
|
|
533
543
|
}, [authService]);
|
|
534
|
-
const logout =
|
|
544
|
+
const logout = React3.useCallback(async () => {
|
|
535
545
|
setLoading(true);
|
|
536
546
|
try {
|
|
537
547
|
await authService.logout();
|
|
@@ -541,7 +551,7 @@ var useAuth = (config) => {
|
|
|
541
551
|
setLoading(false);
|
|
542
552
|
}
|
|
543
553
|
}, [authService]);
|
|
544
|
-
const updateProfile =
|
|
554
|
+
const updateProfile = React3.useCallback(async (data) => {
|
|
545
555
|
setLoading(true);
|
|
546
556
|
try {
|
|
547
557
|
const response = await authService.updateProfile(data);
|
|
@@ -553,7 +563,7 @@ var useAuth = (config) => {
|
|
|
553
563
|
setLoading(false);
|
|
554
564
|
}
|
|
555
565
|
}, [authService]);
|
|
556
|
-
const getProfile =
|
|
566
|
+
const getProfile = React3.useCallback(async () => {
|
|
557
567
|
setLoading(true);
|
|
558
568
|
try {
|
|
559
569
|
const userData = await authService.getProfile();
|
|
@@ -563,7 +573,7 @@ var useAuth = (config) => {
|
|
|
563
573
|
setLoading(false);
|
|
564
574
|
}
|
|
565
575
|
}, [authService]);
|
|
566
|
-
const getAllUsers =
|
|
576
|
+
const getAllUsers = React3.useCallback(async () => {
|
|
567
577
|
setLoading(true);
|
|
568
578
|
try {
|
|
569
579
|
return await authService.getAllUsers();
|
|
@@ -571,7 +581,7 @@ var useAuth = (config) => {
|
|
|
571
581
|
setLoading(false);
|
|
572
582
|
}
|
|
573
583
|
}, [authService]);
|
|
574
|
-
const getUserById =
|
|
584
|
+
const getUserById = React3.useCallback(async (id) => {
|
|
575
585
|
setLoading(true);
|
|
576
586
|
try {
|
|
577
587
|
return await authService.getUserById(id);
|
|
@@ -594,18 +604,69 @@ var useAuth = (config) => {
|
|
|
594
604
|
getUserById
|
|
595
605
|
};
|
|
596
606
|
};
|
|
597
|
-
var
|
|
607
|
+
var ThemeContext = React3.createContext({ theme: "light", mounted: false });
|
|
608
|
+
function AuthThemeProvider({ children }) {
|
|
609
|
+
const [theme, setTheme] = React3.useState("light");
|
|
610
|
+
const [mounted, setMounted] = React3.useState(false);
|
|
611
|
+
React3.useEffect(() => {
|
|
612
|
+
const detectTheme = () => {
|
|
613
|
+
const htmlElement = document.documentElement;
|
|
614
|
+
const bodyElement = document.body;
|
|
615
|
+
if (htmlElement.classList.contains("dark") || bodyElement.classList.contains("dark")) {
|
|
616
|
+
return "dark";
|
|
617
|
+
}
|
|
618
|
+
if (htmlElement.classList.contains("light") || bodyElement.classList.contains("light")) {
|
|
619
|
+
return "light";
|
|
620
|
+
}
|
|
621
|
+
const dataTheme = htmlElement.getAttribute("data-theme") || bodyElement.getAttribute("data-theme");
|
|
622
|
+
if (dataTheme === "dark" || dataTheme === "light") {
|
|
623
|
+
return dataTheme;
|
|
624
|
+
}
|
|
625
|
+
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
626
|
+
return "dark";
|
|
627
|
+
}
|
|
628
|
+
return "light";
|
|
629
|
+
};
|
|
630
|
+
const updateTheme = () => {
|
|
631
|
+
const detectedTheme = detectTheme();
|
|
632
|
+
setTheme(detectedTheme);
|
|
633
|
+
};
|
|
634
|
+
updateTheme();
|
|
635
|
+
setMounted(true);
|
|
636
|
+
const observer = new MutationObserver(updateTheme);
|
|
637
|
+
observer.observe(document.documentElement, {
|
|
638
|
+
attributes: true,
|
|
639
|
+
attributeFilter: ["class", "data-theme"]
|
|
640
|
+
});
|
|
641
|
+
observer.observe(document.body, {
|
|
642
|
+
attributes: true,
|
|
643
|
+
attributeFilter: ["class", "data-theme"]
|
|
644
|
+
});
|
|
645
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
646
|
+
const handleMediaChange = () => updateTheme();
|
|
647
|
+
mediaQuery.addEventListener("change", handleMediaChange);
|
|
648
|
+
return () => {
|
|
649
|
+
observer.disconnect();
|
|
650
|
+
mediaQuery.removeEventListener("change", handleMediaChange);
|
|
651
|
+
};
|
|
652
|
+
}, []);
|
|
653
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: { theme, mounted }, children });
|
|
654
|
+
}
|
|
655
|
+
function useAuthTheme() {
|
|
656
|
+
return React3.useContext(ThemeContext);
|
|
657
|
+
}
|
|
658
|
+
var AuthContext = React3.createContext(void 0);
|
|
598
659
|
var AuthProvider = ({ children, config }) => {
|
|
599
660
|
const authConfig = {
|
|
600
661
|
baseUrl: config?.baseUrl || (typeof window !== "undefined" ? process.env.NEXT_PUBLIC_AUTH_API_URL || process.env.REACT_APP_AUTH_API_URL || "http://localhost:7000" : "http://localhost:7000"),
|
|
601
662
|
localStorageKey: config?.localStorageKey || "auth_token",
|
|
602
663
|
csrfEnabled: config?.csrfEnabled !== void 0 ? config.csrfEnabled : true
|
|
603
664
|
};
|
|
604
|
-
const [authService] =
|
|
605
|
-
const [user, setUser] =
|
|
606
|
-
const [isLoaded, setIsLoaded] =
|
|
607
|
-
const [loading, setLoading] =
|
|
608
|
-
const checkAuthStatus =
|
|
665
|
+
const [authService] = React3.useState(() => new AuthService(authConfig));
|
|
666
|
+
const [user, setUser] = React3.useState(null);
|
|
667
|
+
const [isLoaded, setIsLoaded] = React3.useState(false);
|
|
668
|
+
const [loading, setLoading] = React3.useState(false);
|
|
669
|
+
const checkAuthStatus = React3.useCallback(async () => {
|
|
609
670
|
const authenticated = authService.isAuthenticated();
|
|
610
671
|
if (authenticated) {
|
|
611
672
|
try {
|
|
@@ -620,10 +681,10 @@ var AuthProvider = ({ children, config }) => {
|
|
|
620
681
|
}
|
|
621
682
|
setIsLoaded(true);
|
|
622
683
|
}, [authService]);
|
|
623
|
-
|
|
684
|
+
React3.useEffect(() => {
|
|
624
685
|
checkAuthStatus();
|
|
625
686
|
}, [checkAuthStatus]);
|
|
626
|
-
const signIn =
|
|
687
|
+
const signIn = React3.useCallback(async (data) => {
|
|
627
688
|
setLoading(true);
|
|
628
689
|
try {
|
|
629
690
|
const response = await authService.login(data);
|
|
@@ -635,7 +696,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
635
696
|
setLoading(false);
|
|
636
697
|
}
|
|
637
698
|
}, [authService]);
|
|
638
|
-
const signUp =
|
|
699
|
+
const signUp = React3.useCallback(async (data) => {
|
|
639
700
|
setLoading(true);
|
|
640
701
|
try {
|
|
641
702
|
const response = await authService.register(data);
|
|
@@ -644,7 +705,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
644
705
|
setLoading(false);
|
|
645
706
|
}
|
|
646
707
|
}, [authService]);
|
|
647
|
-
const signOut =
|
|
708
|
+
const signOut = React3.useCallback(async () => {
|
|
648
709
|
setLoading(true);
|
|
649
710
|
try {
|
|
650
711
|
await authService.logout();
|
|
@@ -653,7 +714,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
653
714
|
setLoading(false);
|
|
654
715
|
}
|
|
655
716
|
}, [authService]);
|
|
656
|
-
const verify =
|
|
717
|
+
const verify = React3.useCallback(async (data) => {
|
|
657
718
|
setLoading(true);
|
|
658
719
|
try {
|
|
659
720
|
const response = await authService.verify(data);
|
|
@@ -665,7 +726,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
665
726
|
setLoading(false);
|
|
666
727
|
}
|
|
667
728
|
}, [authService]);
|
|
668
|
-
const verifyEmailToken =
|
|
729
|
+
const verifyEmailToken = React3.useCallback(async (token) => {
|
|
669
730
|
setLoading(true);
|
|
670
731
|
try {
|
|
671
732
|
const response = await authService.verifyEmailToken(token);
|
|
@@ -677,7 +738,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
677
738
|
setLoading(false);
|
|
678
739
|
}
|
|
679
740
|
}, [authService]);
|
|
680
|
-
const updateProfile =
|
|
741
|
+
const updateProfile = React3.useCallback(async (data) => {
|
|
681
742
|
setLoading(true);
|
|
682
743
|
try {
|
|
683
744
|
const response = await authService.updateProfile(data);
|
|
@@ -689,7 +750,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
689
750
|
setLoading(false);
|
|
690
751
|
}
|
|
691
752
|
}, [authService]);
|
|
692
|
-
const getProfile =
|
|
753
|
+
const getProfile = React3.useCallback(async () => {
|
|
693
754
|
setLoading(true);
|
|
694
755
|
try {
|
|
695
756
|
const userData = await authService.getProfile();
|
|
@@ -699,13 +760,13 @@ var AuthProvider = ({ children, config }) => {
|
|
|
699
760
|
setLoading(false);
|
|
700
761
|
}
|
|
701
762
|
}, [authService]);
|
|
702
|
-
const signInWithOAuth =
|
|
763
|
+
const signInWithOAuth = React3.useCallback((provider) => {
|
|
703
764
|
authService.loginWithOAuth(provider);
|
|
704
765
|
}, [authService]);
|
|
705
|
-
const linkOAuthProvider =
|
|
766
|
+
const linkOAuthProvider = React3.useCallback((provider) => {
|
|
706
767
|
authService.linkOAuthProvider(provider);
|
|
707
768
|
}, [authService]);
|
|
708
|
-
const unlinkOAuthProvider =
|
|
769
|
+
const unlinkOAuthProvider = React3.useCallback(async (provider) => {
|
|
709
770
|
setLoading(true);
|
|
710
771
|
try {
|
|
711
772
|
return await authService.unlinkOAuthProvider(provider);
|
|
@@ -713,7 +774,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
713
774
|
setLoading(false);
|
|
714
775
|
}
|
|
715
776
|
}, [authService]);
|
|
716
|
-
const forgotPassword =
|
|
777
|
+
const forgotPassword = React3.useCallback(async (email) => {
|
|
717
778
|
setLoading(true);
|
|
718
779
|
try {
|
|
719
780
|
return await authService.forgotPassword(email);
|
|
@@ -721,7 +782,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
721
782
|
setLoading(false);
|
|
722
783
|
}
|
|
723
784
|
}, [authService]);
|
|
724
|
-
const resetPassword =
|
|
785
|
+
const resetPassword = React3.useCallback(async (token, password) => {
|
|
725
786
|
setLoading(true);
|
|
726
787
|
try {
|
|
727
788
|
return await authService.resetPassword(token, password);
|
|
@@ -729,7 +790,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
729
790
|
setLoading(false);
|
|
730
791
|
}
|
|
731
792
|
}, [authService]);
|
|
732
|
-
const changePassword =
|
|
793
|
+
const changePassword = React3.useCallback(async (oldPassword, newPassword) => {
|
|
733
794
|
setLoading(true);
|
|
734
795
|
try {
|
|
735
796
|
return await authService.changePassword(oldPassword, newPassword);
|
|
@@ -737,7 +798,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
737
798
|
setLoading(false);
|
|
738
799
|
}
|
|
739
800
|
}, [authService]);
|
|
740
|
-
const updateAvatar =
|
|
801
|
+
const updateAvatar = React3.useCallback(async (avatar) => {
|
|
741
802
|
setLoading(true);
|
|
742
803
|
try {
|
|
743
804
|
const response = await authService.updateAvatar(avatar);
|
|
@@ -749,7 +810,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
749
810
|
setLoading(false);
|
|
750
811
|
}
|
|
751
812
|
}, [authService]);
|
|
752
|
-
const requestEmailChange =
|
|
813
|
+
const requestEmailChange = React3.useCallback(async (newEmail) => {
|
|
753
814
|
setLoading(true);
|
|
754
815
|
try {
|
|
755
816
|
return await authService.requestEmailChange(newEmail);
|
|
@@ -757,7 +818,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
757
818
|
setLoading(false);
|
|
758
819
|
}
|
|
759
820
|
}, [authService]);
|
|
760
|
-
const verifyEmailChange =
|
|
821
|
+
const verifyEmailChange = React3.useCallback(async (token) => {
|
|
761
822
|
setLoading(true);
|
|
762
823
|
try {
|
|
763
824
|
const response = await authService.verifyEmailChange(token);
|
|
@@ -769,7 +830,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
769
830
|
setLoading(false);
|
|
770
831
|
}
|
|
771
832
|
}, [authService]);
|
|
772
|
-
const generate2FA =
|
|
833
|
+
const generate2FA = React3.useCallback(async () => {
|
|
773
834
|
setLoading(true);
|
|
774
835
|
try {
|
|
775
836
|
return await authService.generate2FA();
|
|
@@ -777,7 +838,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
777
838
|
setLoading(false);
|
|
778
839
|
}
|
|
779
840
|
}, [authService]);
|
|
780
|
-
const enable2FA =
|
|
841
|
+
const enable2FA = React3.useCallback(async (token) => {
|
|
781
842
|
setLoading(true);
|
|
782
843
|
try {
|
|
783
844
|
return await authService.enable2FA(token);
|
|
@@ -785,7 +846,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
785
846
|
setLoading(false);
|
|
786
847
|
}
|
|
787
848
|
}, [authService]);
|
|
788
|
-
const disable2FA =
|
|
849
|
+
const disable2FA = React3.useCallback(async (token) => {
|
|
789
850
|
setLoading(true);
|
|
790
851
|
try {
|
|
791
852
|
return await authService.disable2FA(token);
|
|
@@ -793,7 +854,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
793
854
|
setLoading(false);
|
|
794
855
|
}
|
|
795
856
|
}, [authService]);
|
|
796
|
-
const validate2FA =
|
|
857
|
+
const validate2FA = React3.useCallback(async (token) => {
|
|
797
858
|
setLoading(true);
|
|
798
859
|
try {
|
|
799
860
|
return await authService.validate2FA(token);
|
|
@@ -801,7 +862,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
801
862
|
setLoading(false);
|
|
802
863
|
}
|
|
803
864
|
}, [authService]);
|
|
804
|
-
const getSessions =
|
|
865
|
+
const getSessions = React3.useCallback(async () => {
|
|
805
866
|
setLoading(true);
|
|
806
867
|
try {
|
|
807
868
|
return await authService.getSessions();
|
|
@@ -809,7 +870,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
809
870
|
setLoading(false);
|
|
810
871
|
}
|
|
811
872
|
}, [authService]);
|
|
812
|
-
const revokeSession =
|
|
873
|
+
const revokeSession = React3.useCallback(async (sessionId) => {
|
|
813
874
|
setLoading(true);
|
|
814
875
|
try {
|
|
815
876
|
return await authService.revokeSession(sessionId);
|
|
@@ -817,7 +878,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
817
878
|
setLoading(false);
|
|
818
879
|
}
|
|
819
880
|
}, [authService]);
|
|
820
|
-
const revokeAllSessions =
|
|
881
|
+
const revokeAllSessions = React3.useCallback(async () => {
|
|
821
882
|
setLoading(true);
|
|
822
883
|
try {
|
|
823
884
|
const response = await authService.revokeAllSessions();
|
|
@@ -857,15 +918,276 @@ var AuthProvider = ({ children, config }) => {
|
|
|
857
918
|
revokeAllSessions,
|
|
858
919
|
authService
|
|
859
920
|
};
|
|
860
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children });
|
|
921
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(AuthThemeProvider, { children }) });
|
|
861
922
|
};
|
|
862
923
|
var useAuth2 = () => {
|
|
863
|
-
const context =
|
|
924
|
+
const context = React3.useContext(AuthContext);
|
|
864
925
|
if (context === void 0) {
|
|
865
926
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
866
927
|
}
|
|
867
928
|
return context;
|
|
868
929
|
};
|
|
930
|
+
|
|
931
|
+
// src/react/hooks/useThemeColors.ts
|
|
932
|
+
var lightTheme = {
|
|
933
|
+
bgPrimary: "var(--auth-bg-primary, #ffffff)",
|
|
934
|
+
bgSecondary: "var(--auth-bg-secondary, #f8fafc)",
|
|
935
|
+
bgHover: "var(--auth-bg-hover, #f1f5f9)",
|
|
936
|
+
textPrimary: "var(--auth-text-primary, #0f172a)",
|
|
937
|
+
textSecondary: "var(--auth-text-secondary, #475569)",
|
|
938
|
+
textTertiary: "var(--auth-text-tertiary, #94a3b8)",
|
|
939
|
+
borderPrimary: "var(--auth-border-primary, #e2e8f0)",
|
|
940
|
+
borderSecondary: "var(--auth-border-secondary, #cbd5e1)",
|
|
941
|
+
buttonPrimary: "var(--auth-button-primary, #3b82f6)",
|
|
942
|
+
buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
|
|
943
|
+
errorBg: "var(--auth-error-bg, #fef2f2)",
|
|
944
|
+
errorText: "var(--auth-error-text, #dc2626)",
|
|
945
|
+
errorBorder: "var(--auth-error-border, #fecaca)",
|
|
946
|
+
successBg: "var(--auth-success-bg, #f0fdf4)",
|
|
947
|
+
successText: "var(--auth-success-text, #16a34a)",
|
|
948
|
+
successBorder: "var(--auth-success-border, #bbf7d0)"
|
|
949
|
+
};
|
|
950
|
+
var darkTheme = {
|
|
951
|
+
bgPrimary: "var(--auth-bg-primary, #1f2937)",
|
|
952
|
+
bgSecondary: "var(--auth-bg-secondary, #111827)",
|
|
953
|
+
bgHover: "var(--auth-bg-hover, #374151)",
|
|
954
|
+
textPrimary: "var(--auth-text-primary, #f9fafb)",
|
|
955
|
+
textSecondary: "var(--auth-text-secondary, #e5e7eb)",
|
|
956
|
+
textTertiary: "var(--auth-text-tertiary, #d1d5db)",
|
|
957
|
+
borderPrimary: "var(--auth-border-primary, #374151)",
|
|
958
|
+
borderSecondary: "var(--auth-border-secondary, #4b5563)",
|
|
959
|
+
buttonPrimary: "var(--auth-button-primary, #3b82f6)",
|
|
960
|
+
buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
|
|
961
|
+
errorBg: "var(--auth-error-bg, #7f1d1d)",
|
|
962
|
+
errorText: "var(--auth-error-text, #fecaca)",
|
|
963
|
+
errorBorder: "var(--auth-error-border, #991b1b)",
|
|
964
|
+
successBg: "var(--auth-success-bg, #14532d)",
|
|
965
|
+
successText: "var(--auth-success-text, #bbf7d0)",
|
|
966
|
+
successBorder: "var(--auth-success-border, #166534)"
|
|
967
|
+
};
|
|
968
|
+
function useThemeColors() {
|
|
969
|
+
const { theme } = useAuthTheme();
|
|
970
|
+
return theme === "dark" ? darkTheme : lightTheme;
|
|
971
|
+
}
|
|
972
|
+
var CustomPhoneInput = React3__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
973
|
+
"input",
|
|
974
|
+
{
|
|
975
|
+
...props,
|
|
976
|
+
ref,
|
|
977
|
+
className: "PhoneInputInput"
|
|
978
|
+
}
|
|
979
|
+
));
|
|
980
|
+
CustomPhoneInput.displayName = "CustomPhoneInput";
|
|
981
|
+
var PhoneInput = ({
|
|
982
|
+
value,
|
|
983
|
+
onChange,
|
|
984
|
+
disabled = false,
|
|
985
|
+
required = false,
|
|
986
|
+
placeholder = "Enter phone number",
|
|
987
|
+
id = "phone",
|
|
988
|
+
style = {}
|
|
989
|
+
}) => {
|
|
990
|
+
const colors = useThemeColors();
|
|
991
|
+
const [defaultCountry, setDefaultCountry] = React3.useState("US");
|
|
992
|
+
const styleContent = React3.useMemo(() => `
|
|
993
|
+
.PhoneInput {
|
|
994
|
+
display: flex;
|
|
995
|
+
align-items: center;
|
|
996
|
+
gap: 8px;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
.PhoneInputCountry {
|
|
1000
|
+
position: relative;
|
|
1001
|
+
align-self: stretch;
|
|
1002
|
+
display: flex;
|
|
1003
|
+
align-items: center;
|
|
1004
|
+
padding: 0 8px;
|
|
1005
|
+
border: 1px solid ${colors.borderSecondary};
|
|
1006
|
+
border-radius: 8px;
|
|
1007
|
+
background-color: ${colors.bgSecondary};
|
|
1008
|
+
transition: all 0.2s ease;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
.PhoneInputCountry:focus-within {
|
|
1012
|
+
border-color: ${colors.buttonPrimary};
|
|
1013
|
+
outline: 2px solid ${colors.buttonPrimary}40;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
.PhoneInputCountryIcon {
|
|
1017
|
+
width: 24px;
|
|
1018
|
+
height: 24px;
|
|
1019
|
+
margin-right: 4px;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
.PhoneInputCountryIcon--border {
|
|
1023
|
+
box-shadow: none;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
.PhoneInputCountrySelect {
|
|
1027
|
+
position: absolute;
|
|
1028
|
+
top: 0;
|
|
1029
|
+
left: 0;
|
|
1030
|
+
height: 100%;
|
|
1031
|
+
width: 100%;
|
|
1032
|
+
z-index: 1;
|
|
1033
|
+
border: 0;
|
|
1034
|
+
opacity: 0;
|
|
1035
|
+
cursor: pointer;
|
|
1036
|
+
color: ${colors.textPrimary};
|
|
1037
|
+
background-color: ${colors.bgSecondary};
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
.PhoneInputCountrySelect:disabled {
|
|
1041
|
+
cursor: not-allowed;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/* Dropdown menu styling */
|
|
1045
|
+
.PhoneInputCountrySelect option {
|
|
1046
|
+
background-color: ${colors.bgPrimary};
|
|
1047
|
+
color: ${colors.textPrimary};
|
|
1048
|
+
padding: 8px 12px;
|
|
1049
|
+
font-size: 14px;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
.PhoneInputCountrySelect option:hover,
|
|
1053
|
+
.PhoneInputCountrySelect option:focus,
|
|
1054
|
+
.PhoneInputCountrySelect option:checked {
|
|
1055
|
+
background-color: ${colors.buttonPrimary};
|
|
1056
|
+
color: white;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
.PhoneInputCountrySelectArrow {
|
|
1060
|
+
display: block;
|
|
1061
|
+
content: '';
|
|
1062
|
+
width: 0.3em;
|
|
1063
|
+
height: 0.3em;
|
|
1064
|
+
margin-left: 0.35em;
|
|
1065
|
+
border-style: solid;
|
|
1066
|
+
border-color: ${colors.textPrimary};
|
|
1067
|
+
border-top-width: 0;
|
|
1068
|
+
border-bottom-width: 1px;
|
|
1069
|
+
border-left-width: 0;
|
|
1070
|
+
border-right-width: 1px;
|
|
1071
|
+
transform: rotate(45deg);
|
|
1072
|
+
opacity: 0.7;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
.PhoneInputInput {
|
|
1076
|
+
flex: 1;
|
|
1077
|
+
min-width: 0;
|
|
1078
|
+
padding: 12px 16px;
|
|
1079
|
+
border: 1px solid ${colors.borderSecondary};
|
|
1080
|
+
border-radius: 8px;
|
|
1081
|
+
font-size: 16px;
|
|
1082
|
+
background-color: ${colors.bgSecondary};
|
|
1083
|
+
color: ${colors.textPrimary};
|
|
1084
|
+
transition: all 0.2s ease;
|
|
1085
|
+
-webkit-text-fill-color: ${colors.textPrimary};
|
|
1086
|
+
-webkit-box-shadow: 0 0 0 1000px ${colors.bgSecondary} inset;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
.PhoneInputInput:focus {
|
|
1090
|
+
border-color: ${colors.buttonPrimary};
|
|
1091
|
+
outline: 2px solid ${colors.buttonPrimary}40;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
.PhoneInputInput:disabled {
|
|
1095
|
+
cursor: not-allowed;
|
|
1096
|
+
opacity: 0.6;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
.PhoneInputInput::placeholder {
|
|
1100
|
+
color: ${colors.textTertiary};
|
|
1101
|
+
opacity: 0.6;
|
|
1102
|
+
}
|
|
1103
|
+
`, [colors]);
|
|
1104
|
+
React3.useEffect(() => {
|
|
1105
|
+
const detectCountry = async () => {
|
|
1106
|
+
try {
|
|
1107
|
+
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1108
|
+
const timezoneToCountry = {
|
|
1109
|
+
"America/New_York": "US",
|
|
1110
|
+
"America/Chicago": "US",
|
|
1111
|
+
"America/Denver": "US",
|
|
1112
|
+
"America/Los_Angeles": "US",
|
|
1113
|
+
"America/Phoenix": "US",
|
|
1114
|
+
"America/Anchorage": "US",
|
|
1115
|
+
"Pacific/Honolulu": "US",
|
|
1116
|
+
"Europe/London": "GB",
|
|
1117
|
+
"Europe/Paris": "FR",
|
|
1118
|
+
"Europe/Berlin": "DE",
|
|
1119
|
+
"Europe/Rome": "IT",
|
|
1120
|
+
"Europe/Madrid": "ES",
|
|
1121
|
+
"Asia/Dubai": "AE",
|
|
1122
|
+
"Asia/Kolkata": "IN",
|
|
1123
|
+
"Asia/Shanghai": "CN",
|
|
1124
|
+
"Asia/Tokyo": "JP",
|
|
1125
|
+
"Asia/Seoul": "KR",
|
|
1126
|
+
"Asia/Singapore": "SG",
|
|
1127
|
+
"Asia/Hong_Kong": "HK",
|
|
1128
|
+
"Australia/Sydney": "AU",
|
|
1129
|
+
"Pacific/Auckland": "NZ",
|
|
1130
|
+
"America/Toronto": "CA",
|
|
1131
|
+
"America/Vancouver": "CA",
|
|
1132
|
+
"America/Mexico_City": "MX",
|
|
1133
|
+
"America/Sao_Paulo": "BR",
|
|
1134
|
+
"America/Buenos_Aires": "AR",
|
|
1135
|
+
"Africa/Cairo": "EG",
|
|
1136
|
+
"Africa/Johannesburg": "ZA",
|
|
1137
|
+
"Africa/Lagos": "NG",
|
|
1138
|
+
"Africa/Nairobi": "KE"
|
|
1139
|
+
};
|
|
1140
|
+
const detectedCountry = timezoneToCountry[timezone];
|
|
1141
|
+
if (detectedCountry) {
|
|
1142
|
+
setDefaultCountry(detectedCountry);
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
const response = await fetch("https://ipapi.co/json/", {
|
|
1146
|
+
signal: AbortSignal.timeout(3e3)
|
|
1147
|
+
// 3 second timeout
|
|
1148
|
+
});
|
|
1149
|
+
if (response.ok) {
|
|
1150
|
+
const data = await response.json();
|
|
1151
|
+
if (data.country_code) {
|
|
1152
|
+
setDefaultCountry(data.country_code);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
} catch (error) {
|
|
1156
|
+
console.log("Country detection failed, using default US");
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
detectCountry();
|
|
1160
|
+
}, []);
|
|
1161
|
+
const handleChange = React3.useMemo(() => (val) => {
|
|
1162
|
+
onChange(val || "");
|
|
1163
|
+
}, [onChange]);
|
|
1164
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1165
|
+
"div",
|
|
1166
|
+
{
|
|
1167
|
+
style: {
|
|
1168
|
+
width: "100%",
|
|
1169
|
+
...style
|
|
1170
|
+
},
|
|
1171
|
+
children: [
|
|
1172
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: styleContent }),
|
|
1173
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1174
|
+
PhoneInputWithCountry__default.default,
|
|
1175
|
+
{
|
|
1176
|
+
id,
|
|
1177
|
+
international: true,
|
|
1178
|
+
defaultCountry,
|
|
1179
|
+
value: value || "",
|
|
1180
|
+
onChange: handleChange,
|
|
1181
|
+
disabled,
|
|
1182
|
+
placeholder,
|
|
1183
|
+
inputComponent: CustomPhoneInput
|
|
1184
|
+
},
|
|
1185
|
+
id
|
|
1186
|
+
)
|
|
1187
|
+
]
|
|
1188
|
+
}
|
|
1189
|
+
);
|
|
1190
|
+
};
|
|
869
1191
|
var LoginForm = ({
|
|
870
1192
|
onSuccess,
|
|
871
1193
|
onLoginSuccess,
|
|
@@ -875,15 +1197,18 @@ var LoginForm = ({
|
|
|
875
1197
|
oauthProviders = ["google", "github"],
|
|
876
1198
|
showOAuthButtons = true
|
|
877
1199
|
}) => {
|
|
878
|
-
const
|
|
879
|
-
const [
|
|
880
|
-
const [
|
|
881
|
-
const [
|
|
882
|
-
const [
|
|
883
|
-
const [
|
|
884
|
-
const [
|
|
1200
|
+
const colors = useThemeColors();
|
|
1201
|
+
const [email, setEmail] = React3.useState("");
|
|
1202
|
+
const [phoneNumber, setPhoneNumber] = React3.useState("");
|
|
1203
|
+
const [usePhone, setUsePhone] = React3.useState(false);
|
|
1204
|
+
const [password, setPassword] = React3.useState("");
|
|
1205
|
+
const [usePassword, setUsePassword] = React3.useState(false);
|
|
1206
|
+
const [showPassword, setShowPassword] = React3.useState(false);
|
|
1207
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
1208
|
+
const [error, setError] = React3.useState(null);
|
|
1209
|
+
const [rememberMe, setRememberMe] = React3.useState(false);
|
|
885
1210
|
const { login } = useAuth({
|
|
886
|
-
baseUrl: config?.baseUrl ||
|
|
1211
|
+
baseUrl: config?.baseUrl || "http://localhost:7000"
|
|
887
1212
|
});
|
|
888
1213
|
const handleSubmit = async (e) => {
|
|
889
1214
|
e.preventDefault();
|
|
@@ -891,20 +1216,28 @@ var LoginForm = ({
|
|
|
891
1216
|
setError(null);
|
|
892
1217
|
try {
|
|
893
1218
|
let response;
|
|
1219
|
+
const loginData = {};
|
|
1220
|
+
if (usePhone && phoneNumber) {
|
|
1221
|
+
loginData.phoneNumber = phoneNumber;
|
|
1222
|
+
} else if (email) {
|
|
1223
|
+
loginData.email = email;
|
|
1224
|
+
}
|
|
894
1225
|
if (usePassword) {
|
|
895
|
-
|
|
1226
|
+
loginData.password = password;
|
|
1227
|
+
response = await login(loginData);
|
|
896
1228
|
} else {
|
|
897
|
-
response = await login(
|
|
1229
|
+
response = await login(loginData);
|
|
898
1230
|
}
|
|
899
1231
|
if (response.success) {
|
|
900
1232
|
onSuccess?.(response);
|
|
901
1233
|
if (onLoginSuccess) {
|
|
902
|
-
|
|
903
|
-
|
|
1234
|
+
const identifier = usePhone ? phoneNumber : email;
|
|
1235
|
+
if (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.") {
|
|
1236
|
+
onLoginSuccess(identifier, true);
|
|
904
1237
|
} else if (response.token) {
|
|
905
|
-
onLoginSuccess(
|
|
1238
|
+
onLoginSuccess(identifier, false);
|
|
906
1239
|
} else {
|
|
907
|
-
onLoginSuccess(
|
|
1240
|
+
onLoginSuccess(identifier, true);
|
|
908
1241
|
}
|
|
909
1242
|
}
|
|
910
1243
|
} else {
|
|
@@ -926,43 +1259,53 @@ var LoginForm = ({
|
|
|
926
1259
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
927
1260
|
maxWidth: "400px",
|
|
928
1261
|
margin: "0 auto",
|
|
929
|
-
padding: "
|
|
1262
|
+
padding: "24px",
|
|
930
1263
|
borderRadius: "12px",
|
|
931
1264
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
932
|
-
backgroundColor:
|
|
933
|
-
border:
|
|
1265
|
+
backgroundColor: colors.bgPrimary,
|
|
1266
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
934
1267
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
|
|
935
1268
|
display: "flex",
|
|
936
1269
|
flexDirection: "column"
|
|
937
1270
|
}, children: [
|
|
938
1271
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
939
1272
|
textAlign: "center",
|
|
940
|
-
marginBottom: "
|
|
941
|
-
color:
|
|
1273
|
+
marginBottom: "20px",
|
|
1274
|
+
color: colors.textPrimary,
|
|
942
1275
|
fontSize: "24px",
|
|
943
1276
|
fontWeight: 600
|
|
944
1277
|
}, children: usePassword ? "Login with Password" : "Login with OTP" }),
|
|
945
1278
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
946
1279
|
padding: "12px 16px",
|
|
947
|
-
marginBottom: "
|
|
948
|
-
backgroundColor:
|
|
949
|
-
color:
|
|
950
|
-
border:
|
|
1280
|
+
marginBottom: "16px",
|
|
1281
|
+
backgroundColor: colors.errorBg,
|
|
1282
|
+
color: colors.errorText,
|
|
1283
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
951
1284
|
borderRadius: "8px",
|
|
952
1285
|
fontSize: "14px",
|
|
953
1286
|
fontWeight: 500
|
|
954
1287
|
}, children: error }),
|
|
955
1288
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
956
|
-
marginBottom: "
|
|
1289
|
+
marginBottom: "16px"
|
|
957
1290
|
}, children: [
|
|
958
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
|
|
1291
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: usePhone ? "phone" : "email", style: {
|
|
959
1292
|
display: "block",
|
|
960
1293
|
marginBottom: "8px",
|
|
961
1294
|
fontWeight: 500,
|
|
962
|
-
color:
|
|
1295
|
+
color: colors.textSecondary,
|
|
963
1296
|
fontSize: "14px"
|
|
964
|
-
}, children: "Email:" }),
|
|
965
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1297
|
+
}, children: usePhone ? "Phone Number:" : "Email:" }),
|
|
1298
|
+
usePhone ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1299
|
+
PhoneInput,
|
|
1300
|
+
{
|
|
1301
|
+
id: "phone",
|
|
1302
|
+
value: phoneNumber,
|
|
1303
|
+
onChange: setPhoneNumber,
|
|
1304
|
+
required: true,
|
|
1305
|
+
disabled: isLoading,
|
|
1306
|
+
placeholder: "1234567890"
|
|
1307
|
+
}
|
|
1308
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
966
1309
|
"input",
|
|
967
1310
|
{
|
|
968
1311
|
id: "email",
|
|
@@ -974,27 +1317,48 @@ var LoginForm = ({
|
|
|
974
1317
|
style: {
|
|
975
1318
|
width: "100%",
|
|
976
1319
|
padding: "12px 16px",
|
|
977
|
-
border:
|
|
1320
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
978
1321
|
borderRadius: "8px",
|
|
979
1322
|
fontSize: "16px",
|
|
980
1323
|
boxSizing: "border-box",
|
|
981
|
-
color:
|
|
1324
|
+
color: colors.textPrimary,
|
|
982
1325
|
transition: "all 0.2s ease",
|
|
983
|
-
backgroundColor:
|
|
1326
|
+
backgroundColor: colors.bgSecondary
|
|
984
1327
|
},
|
|
985
1328
|
placeholder: "Enter your email"
|
|
986
1329
|
}
|
|
1330
|
+
),
|
|
1331
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1332
|
+
"button",
|
|
1333
|
+
{
|
|
1334
|
+
type: "button",
|
|
1335
|
+
onClick: () => setUsePhone(!usePhone),
|
|
1336
|
+
disabled: isLoading,
|
|
1337
|
+
style: {
|
|
1338
|
+
marginTop: "8px",
|
|
1339
|
+
background: "none",
|
|
1340
|
+
border: "none",
|
|
1341
|
+
color: colors.buttonPrimary,
|
|
1342
|
+
textDecoration: "none",
|
|
1343
|
+
cursor: "pointer",
|
|
1344
|
+
fontSize: "13px",
|
|
1345
|
+
fontWeight: 500,
|
|
1346
|
+
padding: "0",
|
|
1347
|
+
transition: "color 0.2s ease"
|
|
1348
|
+
},
|
|
1349
|
+
children: usePhone ? "Use email instead" : "Use phone number instead"
|
|
1350
|
+
}
|
|
987
1351
|
)
|
|
988
1352
|
] }),
|
|
989
1353
|
usePassword && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
990
|
-
marginBottom: "
|
|
1354
|
+
marginBottom: "16px",
|
|
991
1355
|
position: "relative"
|
|
992
1356
|
}, children: [
|
|
993
1357
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "login-password", style: {
|
|
994
1358
|
display: "block",
|
|
995
1359
|
marginBottom: "8px",
|
|
996
1360
|
fontWeight: 500,
|
|
997
|
-
color:
|
|
1361
|
+
color: colors.textSecondary,
|
|
998
1362
|
fontSize: "14px"
|
|
999
1363
|
}, children: "Password:" }),
|
|
1000
1364
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1009,13 +1373,13 @@ var LoginForm = ({
|
|
|
1009
1373
|
style: {
|
|
1010
1374
|
width: "100%",
|
|
1011
1375
|
padding: "12px 16px",
|
|
1012
|
-
border:
|
|
1376
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1013
1377
|
borderRadius: "8px",
|
|
1014
1378
|
fontSize: "16px",
|
|
1015
1379
|
boxSizing: "border-box",
|
|
1016
|
-
color:
|
|
1380
|
+
color: colors.textPrimary,
|
|
1017
1381
|
transition: "all 0.2s ease",
|
|
1018
|
-
backgroundColor:
|
|
1382
|
+
backgroundColor: colors.bgSecondary
|
|
1019
1383
|
},
|
|
1020
1384
|
placeholder: "Enter your password"
|
|
1021
1385
|
}
|
|
@@ -1033,7 +1397,7 @@ var LoginForm = ({
|
|
|
1033
1397
|
background: "none",
|
|
1034
1398
|
border: "none",
|
|
1035
1399
|
cursor: "pointer",
|
|
1036
|
-
color:
|
|
1400
|
+
color: colors.textTertiary,
|
|
1037
1401
|
fontSize: "14px"
|
|
1038
1402
|
},
|
|
1039
1403
|
children: showPassword ? "Hide" : "Show"
|
|
@@ -1043,8 +1407,8 @@ var LoginForm = ({
|
|
|
1043
1407
|
usePassword && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1044
1408
|
display: "flex",
|
|
1045
1409
|
alignItems: "center",
|
|
1046
|
-
marginBottom: "
|
|
1047
|
-
marginTop: "
|
|
1410
|
+
marginBottom: "12px",
|
|
1411
|
+
marginTop: "4px"
|
|
1048
1412
|
}, children: [
|
|
1049
1413
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1050
1414
|
"input",
|
|
@@ -1068,7 +1432,7 @@ var LoginForm = ({
|
|
|
1068
1432
|
htmlFor: "remember-me",
|
|
1069
1433
|
style: {
|
|
1070
1434
|
fontSize: "14px",
|
|
1071
|
-
color:
|
|
1435
|
+
color: colors.textSecondary,
|
|
1072
1436
|
cursor: "pointer",
|
|
1073
1437
|
userSelect: "none"
|
|
1074
1438
|
},
|
|
@@ -1083,7 +1447,7 @@ var LoginForm = ({
|
|
|
1083
1447
|
disabled: isLoading,
|
|
1084
1448
|
style: {
|
|
1085
1449
|
padding: "14px",
|
|
1086
|
-
backgroundColor:
|
|
1450
|
+
backgroundColor: colors.buttonPrimary,
|
|
1087
1451
|
color: "white",
|
|
1088
1452
|
border: "none",
|
|
1089
1453
|
borderRadius: "8px",
|
|
@@ -1091,16 +1455,16 @@ var LoginForm = ({
|
|
|
1091
1455
|
fontWeight: 600,
|
|
1092
1456
|
cursor: "pointer",
|
|
1093
1457
|
transition: "all 0.2s ease",
|
|
1094
|
-
marginTop: "
|
|
1458
|
+
marginTop: "4px"
|
|
1095
1459
|
},
|
|
1096
1460
|
children: isLoading ? usePassword ? "Logging in..." : "Sending OTP..." : usePassword ? "Login" : "Send OTP"
|
|
1097
1461
|
}
|
|
1098
1462
|
),
|
|
1099
1463
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1100
1464
|
textAlign: "center",
|
|
1101
|
-
marginTop: "
|
|
1102
|
-
paddingTop: "
|
|
1103
|
-
borderTop:
|
|
1465
|
+
marginTop: "16px",
|
|
1466
|
+
paddingTop: "16px",
|
|
1467
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1104
1468
|
}, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1105
1469
|
"button",
|
|
1106
1470
|
{
|
|
@@ -1110,7 +1474,7 @@ var LoginForm = ({
|
|
|
1110
1474
|
style: {
|
|
1111
1475
|
background: "none",
|
|
1112
1476
|
border: "none",
|
|
1113
|
-
color:
|
|
1477
|
+
color: colors.buttonPrimary,
|
|
1114
1478
|
textDecoration: "none",
|
|
1115
1479
|
cursor: "pointer",
|
|
1116
1480
|
fontSize: "14px",
|
|
@@ -1122,9 +1486,9 @@ var LoginForm = ({
|
|
|
1122
1486
|
}
|
|
1123
1487
|
) }),
|
|
1124
1488
|
showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1125
|
-
marginTop: "
|
|
1126
|
-
paddingTop: "
|
|
1127
|
-
borderTop:
|
|
1489
|
+
marginTop: "16px",
|
|
1490
|
+
paddingTop: "16px",
|
|
1491
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1128
1492
|
}, children: [
|
|
1129
1493
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1130
1494
|
position: "relative",
|
|
@@ -1136,15 +1500,15 @@ var LoginForm = ({
|
|
|
1136
1500
|
left: 0,
|
|
1137
1501
|
right: 0,
|
|
1138
1502
|
height: "1px",
|
|
1139
|
-
backgroundColor:
|
|
1503
|
+
backgroundColor: colors.borderPrimary
|
|
1140
1504
|
} }),
|
|
1141
1505
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1142
1506
|
position: "relative",
|
|
1143
1507
|
textAlign: "center"
|
|
1144
1508
|
}, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
|
|
1145
|
-
backgroundColor:
|
|
1509
|
+
backgroundColor: colors.bgPrimary,
|
|
1146
1510
|
padding: "0 12px",
|
|
1147
|
-
color:
|
|
1511
|
+
color: colors.textSecondary,
|
|
1148
1512
|
fontSize: "14px"
|
|
1149
1513
|
}, children: "Or continue with" }) })
|
|
1150
1514
|
] }),
|
|
@@ -1163,10 +1527,10 @@ var LoginForm = ({
|
|
|
1163
1527
|
justifyContent: "center",
|
|
1164
1528
|
gap: "8px",
|
|
1165
1529
|
padding: "10px 16px",
|
|
1166
|
-
backgroundColor:
|
|
1167
|
-
border:
|
|
1530
|
+
backgroundColor: colors.bgPrimary,
|
|
1531
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1168
1532
|
borderRadius: "8px",
|
|
1169
|
-
color:
|
|
1533
|
+
color: colors.textPrimary,
|
|
1170
1534
|
textDecoration: "none",
|
|
1171
1535
|
fontSize: "14px",
|
|
1172
1536
|
fontWeight: 500,
|
|
@@ -1174,12 +1538,12 @@ var LoginForm = ({
|
|
|
1174
1538
|
transition: "all 0.2s ease"
|
|
1175
1539
|
},
|
|
1176
1540
|
onMouseEnter: (e) => {
|
|
1177
|
-
e.currentTarget.style.backgroundColor =
|
|
1178
|
-
e.currentTarget.style.borderColor =
|
|
1541
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
1542
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
1179
1543
|
},
|
|
1180
1544
|
onMouseLeave: (e) => {
|
|
1181
|
-
e.currentTarget.style.backgroundColor =
|
|
1182
|
-
e.currentTarget.style.borderColor =
|
|
1545
|
+
e.currentTarget.style.backgroundColor = colors.bgPrimary;
|
|
1546
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
1183
1547
|
},
|
|
1184
1548
|
children: [
|
|
1185
1549
|
/* @__PURE__ */ jsxRuntime.jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
|
|
@@ -1254,11 +1618,11 @@ var LoginForm = ({
|
|
|
1254
1618
|
] }),
|
|
1255
1619
|
showRegisterLink && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1256
1620
|
textAlign: "center",
|
|
1257
|
-
marginTop: "
|
|
1258
|
-
paddingTop: "
|
|
1259
|
-
borderTop:
|
|
1621
|
+
marginTop: "16px",
|
|
1622
|
+
paddingTop: "16px",
|
|
1623
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1260
1624
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
|
|
1261
|
-
color:
|
|
1625
|
+
color: colors.textSecondary,
|
|
1262
1626
|
fontSize: "14px"
|
|
1263
1627
|
}, children: [
|
|
1264
1628
|
"Don't have an account?",
|
|
@@ -1272,7 +1636,7 @@ var LoginForm = ({
|
|
|
1272
1636
|
style: {
|
|
1273
1637
|
background: "none",
|
|
1274
1638
|
border: "none",
|
|
1275
|
-
color:
|
|
1639
|
+
color: colors.buttonPrimary,
|
|
1276
1640
|
textDecoration: "none",
|
|
1277
1641
|
cursor: "pointer",
|
|
1278
1642
|
fontSize: "14px",
|
|
@@ -1292,16 +1656,19 @@ var RegisterForm = ({
|
|
|
1292
1656
|
showLoginLink = true,
|
|
1293
1657
|
authConfig,
|
|
1294
1658
|
oauthProviders = ["google", "github"],
|
|
1295
|
-
showOAuthButtons = true
|
|
1659
|
+
showOAuthButtons = true,
|
|
1660
|
+
invitationToken
|
|
1296
1661
|
}) => {
|
|
1297
|
-
const
|
|
1298
|
-
const [
|
|
1299
|
-
const [
|
|
1300
|
-
const [
|
|
1301
|
-
const [
|
|
1302
|
-
const [
|
|
1303
|
-
|
|
1304
|
-
|
|
1662
|
+
const colors = useThemeColors();
|
|
1663
|
+
const [name, setName] = React3.useState("");
|
|
1664
|
+
const [email, setEmail] = React3.useState("");
|
|
1665
|
+
const [phoneNumber, setPhoneNumber] = React3.useState("");
|
|
1666
|
+
const [password, setPassword] = React3.useState("");
|
|
1667
|
+
const [confirmPassword, setConfirmPassword] = React3.useState("");
|
|
1668
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
1669
|
+
const [error, setError] = React3.useState(null);
|
|
1670
|
+
React3.useState(false);
|
|
1671
|
+
React3.useState(false);
|
|
1305
1672
|
const getPasswordStrength = (pwd) => {
|
|
1306
1673
|
if (!pwd)
|
|
1307
1674
|
return { strength: "weak", score: 0, label: "" };
|
|
@@ -1324,7 +1691,7 @@ var RegisterForm = ({
|
|
|
1324
1691
|
};
|
|
1325
1692
|
getPasswordStrength(password);
|
|
1326
1693
|
const config = authConfig || {
|
|
1327
|
-
baseUrl:
|
|
1694
|
+
baseUrl: "http://localhost:7000"
|
|
1328
1695
|
};
|
|
1329
1696
|
const { register } = useAuth(config);
|
|
1330
1697
|
const handleSubmit = async (e) => {
|
|
@@ -1342,17 +1709,45 @@ var RegisterForm = ({
|
|
|
1342
1709
|
return;
|
|
1343
1710
|
}
|
|
1344
1711
|
try {
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1712
|
+
if (invitationToken) {
|
|
1713
|
+
const response = await fetch(`${config.baseUrl}/api/v1/auth/signup-with-invitation`, {
|
|
1714
|
+
method: "POST",
|
|
1715
|
+
headers: {
|
|
1716
|
+
"Content-Type": "application/json"
|
|
1717
|
+
},
|
|
1718
|
+
body: JSON.stringify({
|
|
1719
|
+
name,
|
|
1720
|
+
email,
|
|
1721
|
+
password,
|
|
1722
|
+
phoneNumber: phoneNumber || void 0,
|
|
1723
|
+
invitationToken
|
|
1724
|
+
})
|
|
1725
|
+
});
|
|
1726
|
+
const data = await response.json();
|
|
1727
|
+
if (response.ok && data.success) {
|
|
1728
|
+
if (typeof window !== "undefined" && data.token) {
|
|
1729
|
+
localStorage.setItem("auth_token", data.token);
|
|
1730
|
+
}
|
|
1731
|
+
onRegisterSuccess?.();
|
|
1732
|
+
} else {
|
|
1733
|
+
setError(data.error || data.message || "Registration failed");
|
|
1734
|
+
}
|
|
1354
1735
|
} else {
|
|
1355
|
-
|
|
1736
|
+
const registerData = {
|
|
1737
|
+
name,
|
|
1738
|
+
password,
|
|
1739
|
+
frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
|
|
1740
|
+
};
|
|
1741
|
+
if (email)
|
|
1742
|
+
registerData.email = email;
|
|
1743
|
+
if (phoneNumber)
|
|
1744
|
+
registerData.phoneNumber = phoneNumber;
|
|
1745
|
+
const response = await register(registerData);
|
|
1746
|
+
if (response.success) {
|
|
1747
|
+
onRegisterSuccess?.();
|
|
1748
|
+
} else {
|
|
1749
|
+
setError(response.message || "Registration failed");
|
|
1750
|
+
}
|
|
1356
1751
|
}
|
|
1357
1752
|
} catch (err) {
|
|
1358
1753
|
setError(err instanceof Error ? err.message : "An unknown error occurred");
|
|
@@ -1363,40 +1758,40 @@ var RegisterForm = ({
|
|
|
1363
1758
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1364
1759
|
maxWidth: "400px",
|
|
1365
1760
|
margin: "0 auto",
|
|
1366
|
-
padding: "
|
|
1761
|
+
padding: "24px",
|
|
1367
1762
|
borderRadius: "12px",
|
|
1368
1763
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
1369
|
-
backgroundColor:
|
|
1370
|
-
border:
|
|
1764
|
+
backgroundColor: colors.bgPrimary,
|
|
1765
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
1371
1766
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
|
|
1372
1767
|
display: "flex",
|
|
1373
1768
|
flexDirection: "column"
|
|
1374
1769
|
}, children: [
|
|
1375
1770
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
1376
1771
|
textAlign: "center",
|
|
1377
|
-
marginBottom: "
|
|
1378
|
-
color:
|
|
1772
|
+
marginBottom: "20px",
|
|
1773
|
+
color: colors.textPrimary,
|
|
1379
1774
|
fontSize: "24px",
|
|
1380
1775
|
fontWeight: 600
|
|
1381
1776
|
}, children: "Register" }),
|
|
1382
1777
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1383
1778
|
padding: "12px 16px",
|
|
1384
|
-
marginBottom: "
|
|
1385
|
-
backgroundColor:
|
|
1386
|
-
color:
|
|
1387
|
-
border:
|
|
1779
|
+
marginBottom: "16px",
|
|
1780
|
+
backgroundColor: colors.errorBg,
|
|
1781
|
+
color: colors.errorText,
|
|
1782
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
1388
1783
|
borderRadius: "8px",
|
|
1389
1784
|
fontSize: "14px",
|
|
1390
1785
|
fontWeight: 500
|
|
1391
1786
|
}, children: error }),
|
|
1392
1787
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1393
|
-
marginBottom: "
|
|
1788
|
+
marginBottom: "16px"
|
|
1394
1789
|
}, children: [
|
|
1395
1790
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "name", style: {
|
|
1396
1791
|
display: "block",
|
|
1397
1792
|
marginBottom: "8px",
|
|
1398
1793
|
fontWeight: 500,
|
|
1399
|
-
color:
|
|
1794
|
+
color: colors.textSecondary,
|
|
1400
1795
|
fontSize: "14px"
|
|
1401
1796
|
}, children: "Name:" }),
|
|
1402
1797
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1411,26 +1806,26 @@ var RegisterForm = ({
|
|
|
1411
1806
|
style: {
|
|
1412
1807
|
width: "100%",
|
|
1413
1808
|
padding: "12px 16px",
|
|
1414
|
-
border:
|
|
1809
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1415
1810
|
borderRadius: "8px",
|
|
1416
1811
|
fontSize: "16px",
|
|
1417
1812
|
boxSizing: "border-box",
|
|
1418
|
-
color:
|
|
1813
|
+
color: colors.textPrimary,
|
|
1419
1814
|
transition: "all 0.2s ease",
|
|
1420
|
-
backgroundColor:
|
|
1815
|
+
backgroundColor: colors.bgSecondary
|
|
1421
1816
|
},
|
|
1422
1817
|
placeholder: "Enter your name"
|
|
1423
1818
|
}
|
|
1424
1819
|
)
|
|
1425
1820
|
] }),
|
|
1426
1821
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1427
|
-
marginBottom: "
|
|
1822
|
+
marginBottom: "16px"
|
|
1428
1823
|
}, children: [
|
|
1429
1824
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "register-email", style: {
|
|
1430
1825
|
display: "block",
|
|
1431
1826
|
marginBottom: "8px",
|
|
1432
1827
|
fontWeight: 500,
|
|
1433
|
-
color:
|
|
1828
|
+
color: colors.textSecondary,
|
|
1434
1829
|
fontSize: "14px"
|
|
1435
1830
|
}, children: "Email:" }),
|
|
1436
1831
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1440,31 +1835,52 @@ var RegisterForm = ({
|
|
|
1440
1835
|
type: "email",
|
|
1441
1836
|
value: email,
|
|
1442
1837
|
onChange: (e) => setEmail(e.target.value),
|
|
1443
|
-
required:
|
|
1838
|
+
required: !phoneNumber,
|
|
1444
1839
|
disabled: isLoading,
|
|
1445
1840
|
style: {
|
|
1446
1841
|
width: "100%",
|
|
1447
1842
|
padding: "12px 16px",
|
|
1448
|
-
border:
|
|
1843
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1449
1844
|
borderRadius: "8px",
|
|
1450
1845
|
fontSize: "16px",
|
|
1451
1846
|
boxSizing: "border-box",
|
|
1452
|
-
color:
|
|
1847
|
+
color: colors.textPrimary,
|
|
1453
1848
|
transition: "all 0.2s ease",
|
|
1454
|
-
backgroundColor:
|
|
1849
|
+
backgroundColor: colors.bgSecondary
|
|
1455
1850
|
},
|
|
1456
1851
|
placeholder: "Enter your email"
|
|
1457
1852
|
}
|
|
1458
1853
|
)
|
|
1459
1854
|
] }),
|
|
1460
1855
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1461
|
-
marginBottom: "
|
|
1856
|
+
marginBottom: "16px"
|
|
1857
|
+
}, children: [
|
|
1858
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "register-phone", style: {
|
|
1859
|
+
display: "block",
|
|
1860
|
+
marginBottom: "8px",
|
|
1861
|
+
fontWeight: 500,
|
|
1862
|
+
color: colors.textSecondary,
|
|
1863
|
+
fontSize: "14px"
|
|
1864
|
+
}, children: "Phone Number (Optional):" }),
|
|
1865
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1866
|
+
PhoneInput,
|
|
1867
|
+
{
|
|
1868
|
+
id: "register-phone",
|
|
1869
|
+
value: phoneNumber,
|
|
1870
|
+
onChange: setPhoneNumber,
|
|
1871
|
+
disabled: isLoading,
|
|
1872
|
+
placeholder: "1234567890"
|
|
1873
|
+
}
|
|
1874
|
+
)
|
|
1875
|
+
] }),
|
|
1876
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1877
|
+
marginBottom: "16px"
|
|
1462
1878
|
}, children: [
|
|
1463
1879
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
|
|
1464
1880
|
display: "block",
|
|
1465
1881
|
marginBottom: "8px",
|
|
1466
1882
|
fontWeight: 500,
|
|
1467
|
-
color:
|
|
1883
|
+
color: colors.textSecondary,
|
|
1468
1884
|
fontSize: "14px"
|
|
1469
1885
|
}, children: "Password:" }),
|
|
1470
1886
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1479,13 +1895,13 @@ var RegisterForm = ({
|
|
|
1479
1895
|
style: {
|
|
1480
1896
|
width: "100%",
|
|
1481
1897
|
padding: "12px 16px",
|
|
1482
|
-
border:
|
|
1898
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1483
1899
|
borderRadius: "8px",
|
|
1484
1900
|
fontSize: "16px",
|
|
1485
1901
|
boxSizing: "border-box",
|
|
1486
|
-
color:
|
|
1902
|
+
color: colors.textPrimary,
|
|
1487
1903
|
transition: "all 0.2s ease",
|
|
1488
|
-
backgroundColor:
|
|
1904
|
+
backgroundColor: colors.bgSecondary
|
|
1489
1905
|
},
|
|
1490
1906
|
placeholder: "Enter your password",
|
|
1491
1907
|
minLength: 6
|
|
@@ -1493,13 +1909,13 @@ var RegisterForm = ({
|
|
|
1493
1909
|
)
|
|
1494
1910
|
] }),
|
|
1495
1911
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1496
|
-
marginBottom: "
|
|
1912
|
+
marginBottom: "16px"
|
|
1497
1913
|
}, children: [
|
|
1498
1914
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "confirm-password", style: {
|
|
1499
1915
|
display: "block",
|
|
1500
1916
|
marginBottom: "8px",
|
|
1501
1917
|
fontWeight: 500,
|
|
1502
|
-
color:
|
|
1918
|
+
color: colors.textSecondary,
|
|
1503
1919
|
fontSize: "14px"
|
|
1504
1920
|
}, children: "Confirm Password:" }),
|
|
1505
1921
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1514,13 +1930,13 @@ var RegisterForm = ({
|
|
|
1514
1930
|
style: {
|
|
1515
1931
|
width: "100%",
|
|
1516
1932
|
padding: "12px 16px",
|
|
1517
|
-
border:
|
|
1933
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1518
1934
|
borderRadius: "8px",
|
|
1519
1935
|
fontSize: "16px",
|
|
1520
1936
|
boxSizing: "border-box",
|
|
1521
|
-
color:
|
|
1937
|
+
color: colors.textPrimary,
|
|
1522
1938
|
transition: "all 0.2s ease",
|
|
1523
|
-
backgroundColor:
|
|
1939
|
+
backgroundColor: colors.bgSecondary
|
|
1524
1940
|
},
|
|
1525
1941
|
placeholder: "Confirm your password"
|
|
1526
1942
|
}
|
|
@@ -1533,7 +1949,7 @@ var RegisterForm = ({
|
|
|
1533
1949
|
disabled: isLoading,
|
|
1534
1950
|
style: {
|
|
1535
1951
|
padding: "14px",
|
|
1536
|
-
backgroundColor:
|
|
1952
|
+
backgroundColor: colors.buttonPrimary,
|
|
1537
1953
|
color: "white",
|
|
1538
1954
|
border: "none",
|
|
1539
1955
|
borderRadius: "8px",
|
|
@@ -1541,15 +1957,15 @@ var RegisterForm = ({
|
|
|
1541
1957
|
fontWeight: 600,
|
|
1542
1958
|
cursor: "pointer",
|
|
1543
1959
|
transition: "all 0.2s ease",
|
|
1544
|
-
marginTop: "
|
|
1960
|
+
marginTop: "4px"
|
|
1545
1961
|
},
|
|
1546
1962
|
children: isLoading ? "Registering..." : "Register"
|
|
1547
1963
|
}
|
|
1548
1964
|
),
|
|
1549
1965
|
showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1550
|
-
marginTop: "
|
|
1551
|
-
paddingTop: "
|
|
1552
|
-
borderTop:
|
|
1966
|
+
marginTop: "16px",
|
|
1967
|
+
paddingTop: "16px",
|
|
1968
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1553
1969
|
}, children: [
|
|
1554
1970
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1555
1971
|
position: "relative",
|
|
@@ -1561,15 +1977,15 @@ var RegisterForm = ({
|
|
|
1561
1977
|
left: 0,
|
|
1562
1978
|
right: 0,
|
|
1563
1979
|
height: "1px",
|
|
1564
|
-
backgroundColor:
|
|
1980
|
+
backgroundColor: colors.borderPrimary
|
|
1565
1981
|
} }),
|
|
1566
1982
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1567
1983
|
position: "relative",
|
|
1568
1984
|
textAlign: "center"
|
|
1569
1985
|
}, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
|
|
1570
|
-
backgroundColor:
|
|
1986
|
+
backgroundColor: colors.bgPrimary,
|
|
1571
1987
|
padding: "0 12px",
|
|
1572
|
-
color:
|
|
1988
|
+
color: colors.textSecondary,
|
|
1573
1989
|
fontSize: "14px"
|
|
1574
1990
|
}, children: "Or continue with" }) })
|
|
1575
1991
|
] }),
|
|
@@ -1588,10 +2004,10 @@ var RegisterForm = ({
|
|
|
1588
2004
|
justifyContent: "center",
|
|
1589
2005
|
gap: "8px",
|
|
1590
2006
|
padding: "10px 16px",
|
|
1591
|
-
backgroundColor:
|
|
1592
|
-
border:
|
|
2007
|
+
backgroundColor: colors.bgPrimary,
|
|
2008
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1593
2009
|
borderRadius: "8px",
|
|
1594
|
-
color:
|
|
2010
|
+
color: colors.textPrimary,
|
|
1595
2011
|
textDecoration: "none",
|
|
1596
2012
|
fontSize: "14px",
|
|
1597
2013
|
fontWeight: 500,
|
|
@@ -1599,12 +2015,12 @@ var RegisterForm = ({
|
|
|
1599
2015
|
transition: "all 0.2s ease"
|
|
1600
2016
|
},
|
|
1601
2017
|
onMouseEnter: (e) => {
|
|
1602
|
-
e.currentTarget.style.backgroundColor =
|
|
1603
|
-
e.currentTarget.style.borderColor =
|
|
2018
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2019
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
1604
2020
|
},
|
|
1605
2021
|
onMouseLeave: (e) => {
|
|
1606
|
-
e.currentTarget.style.backgroundColor =
|
|
1607
|
-
e.currentTarget.style.borderColor =
|
|
2022
|
+
e.currentTarget.style.backgroundColor = colors.bgPrimary;
|
|
2023
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
1608
2024
|
},
|
|
1609
2025
|
children: [
|
|
1610
2026
|
/* @__PURE__ */ jsxRuntime.jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
|
|
@@ -1679,11 +2095,11 @@ var RegisterForm = ({
|
|
|
1679
2095
|
] }),
|
|
1680
2096
|
showLoginLink && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1681
2097
|
textAlign: "center",
|
|
1682
|
-
marginTop: "
|
|
1683
|
-
paddingTop: "
|
|
1684
|
-
borderTop:
|
|
2098
|
+
marginTop: "16px",
|
|
2099
|
+
paddingTop: "16px",
|
|
2100
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1685
2101
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
|
|
1686
|
-
color:
|
|
2102
|
+
color: colors.textSecondary,
|
|
1687
2103
|
fontSize: "14px"
|
|
1688
2104
|
}, children: [
|
|
1689
2105
|
"Already have an account?",
|
|
@@ -1697,7 +2113,7 @@ var RegisterForm = ({
|
|
|
1697
2113
|
style: {
|
|
1698
2114
|
background: "none",
|
|
1699
2115
|
border: "none",
|
|
1700
|
-
color:
|
|
2116
|
+
color: colors.buttonPrimary,
|
|
1701
2117
|
textDecoration: "none",
|
|
1702
2118
|
cursor: "pointer",
|
|
1703
2119
|
fontSize: "14px",
|
|
@@ -1714,15 +2130,17 @@ var RegisterForm = ({
|
|
|
1714
2130
|
var OtpForm = ({
|
|
1715
2131
|
email,
|
|
1716
2132
|
onVerifySuccess,
|
|
1717
|
-
onBackToLogin
|
|
2133
|
+
onBackToLogin,
|
|
2134
|
+
baseUrl
|
|
1718
2135
|
}) => {
|
|
1719
|
-
const
|
|
1720
|
-
const [
|
|
1721
|
-
const [
|
|
1722
|
-
const [
|
|
1723
|
-
const [
|
|
2136
|
+
const colors = useThemeColors();
|
|
2137
|
+
const [otp, setOtp] = React3.useState("");
|
|
2138
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
2139
|
+
const [error, setError] = React3.useState(null);
|
|
2140
|
+
const [resendCooldown, setResendCooldown] = React3.useState(0);
|
|
2141
|
+
const [resendLoading, setResendLoading] = React3.useState(false);
|
|
1724
2142
|
const { verify, login } = useAuth({
|
|
1725
|
-
baseUrl:
|
|
2143
|
+
baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
|
|
1726
2144
|
});
|
|
1727
2145
|
const handleSubmit = async (e) => {
|
|
1728
2146
|
e.preventDefault();
|
|
@@ -1785,8 +2203,8 @@ var OtpForm = ({
|
|
|
1785
2203
|
padding: "30px",
|
|
1786
2204
|
borderRadius: "12px",
|
|
1787
2205
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
1788
|
-
backgroundColor:
|
|
1789
|
-
border:
|
|
2206
|
+
backgroundColor: colors.bgPrimary,
|
|
2207
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
1790
2208
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
|
|
1791
2209
|
display: "flex",
|
|
1792
2210
|
flexDirection: "column"
|
|
@@ -1794,25 +2212,25 @@ var OtpForm = ({
|
|
|
1794
2212
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
1795
2213
|
textAlign: "center",
|
|
1796
2214
|
marginBottom: "24px",
|
|
1797
|
-
color:
|
|
2215
|
+
color: colors.textPrimary,
|
|
1798
2216
|
fontSize: "24px",
|
|
1799
2217
|
fontWeight: 600
|
|
1800
2218
|
}, children: "Verify OTP" }),
|
|
1801
2219
|
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
|
|
1802
2220
|
textAlign: "center",
|
|
1803
2221
|
marginBottom: "24px",
|
|
1804
|
-
color:
|
|
2222
|
+
color: colors.textSecondary,
|
|
1805
2223
|
fontSize: "14px"
|
|
1806
2224
|
}, children: [
|
|
1807
2225
|
"Enter the 6-digit code sent to ",
|
|
1808
|
-
/* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color:
|
|
2226
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color: colors.textPrimary }, children: email })
|
|
1809
2227
|
] }),
|
|
1810
2228
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1811
2229
|
padding: "12px 16px",
|
|
1812
2230
|
marginBottom: "20px",
|
|
1813
|
-
backgroundColor:
|
|
1814
|
-
color:
|
|
1815
|
-
border:
|
|
2231
|
+
backgroundColor: colors.errorBg,
|
|
2232
|
+
color: colors.errorText,
|
|
2233
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
1816
2234
|
borderRadius: "8px",
|
|
1817
2235
|
fontSize: "14px",
|
|
1818
2236
|
fontWeight: 500
|
|
@@ -1824,7 +2242,7 @@ var OtpForm = ({
|
|
|
1824
2242
|
display: "block",
|
|
1825
2243
|
marginBottom: "8px",
|
|
1826
2244
|
fontWeight: 500,
|
|
1827
|
-
color:
|
|
2245
|
+
color: colors.textSecondary,
|
|
1828
2246
|
fontSize: "14px"
|
|
1829
2247
|
}, children: "OTP Code:" }),
|
|
1830
2248
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1839,13 +2257,13 @@ var OtpForm = ({
|
|
|
1839
2257
|
style: {
|
|
1840
2258
|
width: "100%",
|
|
1841
2259
|
padding: "12px 16px",
|
|
1842
|
-
border:
|
|
2260
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1843
2261
|
borderRadius: "8px",
|
|
1844
2262
|
fontSize: "20px",
|
|
1845
2263
|
boxSizing: "border-box",
|
|
1846
|
-
color:
|
|
2264
|
+
color: colors.textPrimary,
|
|
1847
2265
|
transition: "all 0.2s ease",
|
|
1848
|
-
backgroundColor:
|
|
2266
|
+
backgroundColor: colors.bgSecondary,
|
|
1849
2267
|
textAlign: "center",
|
|
1850
2268
|
letterSpacing: "5px"
|
|
1851
2269
|
},
|
|
@@ -1862,7 +2280,7 @@ var OtpForm = ({
|
|
|
1862
2280
|
disabled: isLoading || otp.length !== 6,
|
|
1863
2281
|
style: {
|
|
1864
2282
|
padding: "14px",
|
|
1865
|
-
backgroundColor:
|
|
2283
|
+
backgroundColor: colors.buttonPrimary,
|
|
1866
2284
|
color: "white",
|
|
1867
2285
|
border: "none",
|
|
1868
2286
|
borderRadius: "8px",
|
|
@@ -1879,7 +2297,7 @@ var OtpForm = ({
|
|
|
1879
2297
|
textAlign: "center",
|
|
1880
2298
|
marginTop: "20px",
|
|
1881
2299
|
paddingTop: "20px",
|
|
1882
|
-
borderTop:
|
|
2300
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1883
2301
|
}, children: [
|
|
1884
2302
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1885
2303
|
"button",
|
|
@@ -1890,7 +2308,7 @@ var OtpForm = ({
|
|
|
1890
2308
|
style: {
|
|
1891
2309
|
background: "none",
|
|
1892
2310
|
border: "none",
|
|
1893
|
-
color: resendCooldown > 0 ?
|
|
2311
|
+
color: resendCooldown > 0 ? colors.textTertiary : colors.buttonPrimary,
|
|
1894
2312
|
textDecoration: "none",
|
|
1895
2313
|
cursor: resendCooldown > 0 ? "not-allowed" : "pointer",
|
|
1896
2314
|
fontSize: "14px",
|
|
@@ -1913,7 +2331,7 @@ var OtpForm = ({
|
|
|
1913
2331
|
style: {
|
|
1914
2332
|
background: "none",
|
|
1915
2333
|
border: "none",
|
|
1916
|
-
color:
|
|
2334
|
+
color: colors.buttonPrimary,
|
|
1917
2335
|
textDecoration: "none",
|
|
1918
2336
|
cursor: "pointer",
|
|
1919
2337
|
fontSize: "14px",
|
|
@@ -1932,9 +2350,9 @@ var AuthFlow = ({
|
|
|
1932
2350
|
initialStep = "login",
|
|
1933
2351
|
showTitle = true
|
|
1934
2352
|
}) => {
|
|
1935
|
-
const [step, setStep] =
|
|
1936
|
-
const [email, setEmail] =
|
|
1937
|
-
const [message, setMessage] =
|
|
2353
|
+
const [step, setStep] = React3.useState(initialStep);
|
|
2354
|
+
const [email, setEmail] = React3.useState("");
|
|
2355
|
+
const [message, setMessage] = React3.useState(null);
|
|
1938
2356
|
const handleLoginSuccess = (email2, needsOtpVerification) => {
|
|
1939
2357
|
setEmail(email2);
|
|
1940
2358
|
if (needsOtpVerification) {
|
|
@@ -2069,13 +2487,13 @@ var EmailVerificationPage = ({
|
|
|
2069
2487
|
onVerificationError,
|
|
2070
2488
|
baseUrl
|
|
2071
2489
|
}) => {
|
|
2072
|
-
const [isLoading, setIsLoading] =
|
|
2073
|
-
const [message, setMessage] =
|
|
2074
|
-
const [isSuccess, setIsSuccess] =
|
|
2490
|
+
const [isLoading, setIsLoading] = React3.useState(true);
|
|
2491
|
+
const [message, setMessage] = React3.useState("");
|
|
2492
|
+
const [isSuccess, setIsSuccess] = React3.useState(false);
|
|
2075
2493
|
const { verifyEmailToken } = useAuth({
|
|
2076
2494
|
baseUrl: baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
|
|
2077
2495
|
});
|
|
2078
|
-
|
|
2496
|
+
React3.useEffect(() => {
|
|
2079
2497
|
const verifyEmail = async () => {
|
|
2080
2498
|
if (!token) {
|
|
2081
2499
|
setIsLoading(false);
|
|
@@ -2180,18 +2598,31 @@ var EmailVerificationPage = ({
|
|
|
2180
2598
|
] })
|
|
2181
2599
|
] }) });
|
|
2182
2600
|
};
|
|
2601
|
+
var ThemeWrapper = React3.forwardRef(
|
|
2602
|
+
({ children, className = "", style }, ref) => {
|
|
2603
|
+
const { theme, mounted } = useAuthTheme();
|
|
2604
|
+
if (!mounted) {
|
|
2605
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className, style, children });
|
|
2606
|
+
}
|
|
2607
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: `${theme} ${className}`, style, children });
|
|
2608
|
+
}
|
|
2609
|
+
);
|
|
2610
|
+
ThemeWrapper.displayName = "ThemeWrapper";
|
|
2183
2611
|
var SignIn = ({ redirectUrl, appearance }) => {
|
|
2184
2612
|
const { signIn, isSignedIn, loading: authLoading } = useAuth2();
|
|
2185
|
-
const
|
|
2186
|
-
const [
|
|
2187
|
-
const [
|
|
2188
|
-
const [
|
|
2189
|
-
const [
|
|
2190
|
-
const [
|
|
2191
|
-
const [
|
|
2192
|
-
const [
|
|
2193
|
-
const [
|
|
2194
|
-
|
|
2613
|
+
const colors = useThemeColors();
|
|
2614
|
+
const [email, setEmail] = React3.useState("");
|
|
2615
|
+
const [phoneNumber, setPhoneNumber] = React3.useState("");
|
|
2616
|
+
const [password, setPassword] = React3.useState("");
|
|
2617
|
+
const [otp, setOtp] = React3.useState("");
|
|
2618
|
+
const [usePassword, setUsePassword] = React3.useState(false);
|
|
2619
|
+
const [usePhone, setUsePhone] = React3.useState(false);
|
|
2620
|
+
const [showPassword, setShowPassword] = React3.useState(false);
|
|
2621
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
2622
|
+
const [error, setError] = React3.useState(null);
|
|
2623
|
+
const [needsOtp, setNeedsOtp] = React3.useState(false);
|
|
2624
|
+
const [success, setSuccess] = React3.useState(null);
|
|
2625
|
+
React3.useEffect(() => {
|
|
2195
2626
|
if (isSignedIn && redirectUrl) {
|
|
2196
2627
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
2197
2628
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -2204,25 +2635,26 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
2204
2635
|
setError(null);
|
|
2205
2636
|
setSuccess(null);
|
|
2206
2637
|
try {
|
|
2638
|
+
const loginData = usePhone ? { phoneNumber } : { email };
|
|
2207
2639
|
if (needsOtp) {
|
|
2208
|
-
const response = await signIn({
|
|
2640
|
+
const response = await signIn({ ...loginData, otp });
|
|
2209
2641
|
if (response.success) {
|
|
2210
2642
|
setSuccess("Login successful!");
|
|
2211
2643
|
} else {
|
|
2212
2644
|
setError(response.message || "OTP verification failed");
|
|
2213
2645
|
}
|
|
2214
2646
|
} else if (usePassword) {
|
|
2215
|
-
const response = await signIn({
|
|
2647
|
+
const response = await signIn({ ...loginData, password });
|
|
2216
2648
|
if (response.success) {
|
|
2217
2649
|
setSuccess("Login successful!");
|
|
2218
2650
|
} else {
|
|
2219
2651
|
setError(response.message || "Login failed");
|
|
2220
2652
|
}
|
|
2221
2653
|
} else {
|
|
2222
|
-
const response = await signIn(
|
|
2223
|
-
if (response.success && response.message === "OTP sent to your email.") {
|
|
2654
|
+
const response = await signIn(loginData);
|
|
2655
|
+
if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
|
|
2224
2656
|
setNeedsOtp(true);
|
|
2225
|
-
setSuccess("OTP sent to your email. Please check your inbox.");
|
|
2657
|
+
setSuccess(usePhone ? "OTP sent to your phone. Please check your messages." : "OTP sent to your email. Please check your inbox.");
|
|
2226
2658
|
} else {
|
|
2227
2659
|
setError(response.message || "Failed to send OTP");
|
|
2228
2660
|
}
|
|
@@ -2240,238 +2672,366 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
2240
2672
|
setSuccess(null);
|
|
2241
2673
|
setOtp("");
|
|
2242
2674
|
};
|
|
2675
|
+
const toggleLoginMethod = () => {
|
|
2676
|
+
setUsePhone(!usePhone);
|
|
2677
|
+
setNeedsOtp(false);
|
|
2678
|
+
setError(null);
|
|
2679
|
+
setSuccess(null);
|
|
2680
|
+
setOtp("");
|
|
2681
|
+
setEmail("");
|
|
2682
|
+
setPhoneNumber("");
|
|
2683
|
+
};
|
|
2243
2684
|
if (authLoading) {
|
|
2244
2685
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading..." }) });
|
|
2245
2686
|
}
|
|
2246
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
padding: "12px 16px",
|
|
2266
|
-
marginBottom: "20px",
|
|
2267
|
-
backgroundColor: "#fee",
|
|
2268
|
-
color: "#c33",
|
|
2269
|
-
border: "1px solid #fcc",
|
|
2270
|
-
borderRadius: "8px",
|
|
2271
|
-
fontSize: "14px"
|
|
2272
|
-
}, children: error }),
|
|
2273
|
-
success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2274
|
-
padding: "12px 16px",
|
|
2275
|
-
marginBottom: "20px",
|
|
2276
|
-
backgroundColor: "#efe",
|
|
2277
|
-
color: "#3c3",
|
|
2278
|
-
border: "1px solid #cfc",
|
|
2279
|
-
borderRadius: "8px",
|
|
2280
|
-
fontSize: "14px"
|
|
2281
|
-
}, children: success }),
|
|
2282
|
-
!needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2283
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
|
|
2284
|
-
display: "block",
|
|
2285
|
-
marginBottom: "8px",
|
|
2286
|
-
fontWeight: 500,
|
|
2287
|
-
color: "#374151",
|
|
2288
|
-
fontSize: "14px"
|
|
2289
|
-
}, children: "Email" }),
|
|
2290
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2291
|
-
"input",
|
|
2292
|
-
{
|
|
2293
|
-
id: "email",
|
|
2294
|
-
type: "email",
|
|
2295
|
-
value: email,
|
|
2296
|
-
onChange: (e) => setEmail(e.target.value),
|
|
2297
|
-
required: true,
|
|
2298
|
-
disabled: isLoading,
|
|
2299
|
-
style: {
|
|
2300
|
-
width: "100%",
|
|
2301
|
-
padding: "12px 16px",
|
|
2302
|
-
border: "1px solid #ddd",
|
|
2303
|
-
borderRadius: "8px",
|
|
2304
|
-
fontSize: "16px",
|
|
2305
|
-
boxSizing: "border-box",
|
|
2306
|
-
...appearance?.elements?.formFieldInput
|
|
2307
|
-
},
|
|
2308
|
-
placeholder: "Enter your email"
|
|
2309
|
-
}
|
|
2310
|
-
)
|
|
2311
|
-
] }),
|
|
2312
|
-
usePassword && !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2313
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
|
|
2314
|
-
display: "block",
|
|
2315
|
-
marginBottom: "8px",
|
|
2316
|
-
fontWeight: 500,
|
|
2317
|
-
color: "#374151",
|
|
2318
|
-
fontSize: "14px"
|
|
2319
|
-
}, children: "Password" }),
|
|
2320
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2321
|
-
"input",
|
|
2322
|
-
{
|
|
2323
|
-
id: "password",
|
|
2324
|
-
type: showPassword ? "text" : "password",
|
|
2325
|
-
value: password,
|
|
2326
|
-
onChange: (e) => setPassword(e.target.value),
|
|
2327
|
-
required: true,
|
|
2328
|
-
disabled: isLoading,
|
|
2329
|
-
style: {
|
|
2330
|
-
width: "100%",
|
|
2331
|
-
padding: "12px 16px",
|
|
2332
|
-
border: "1px solid #ddd",
|
|
2333
|
-
borderRadius: "8px",
|
|
2334
|
-
fontSize: "16px",
|
|
2335
|
-
boxSizing: "border-box",
|
|
2336
|
-
...appearance?.elements?.formFieldInput
|
|
2337
|
-
},
|
|
2338
|
-
placeholder: "Enter your password"
|
|
2339
|
-
}
|
|
2340
|
-
),
|
|
2341
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2342
|
-
"button",
|
|
2343
|
-
{
|
|
2344
|
-
type: "button",
|
|
2345
|
-
onClick: () => setShowPassword(!showPassword),
|
|
2346
|
-
style: {
|
|
2347
|
-
position: "absolute",
|
|
2348
|
-
right: "12px",
|
|
2349
|
-
top: "38px",
|
|
2350
|
-
background: "none",
|
|
2351
|
-
border: "none",
|
|
2352
|
-
cursor: "pointer",
|
|
2353
|
-
color: "#666",
|
|
2354
|
-
fontSize: "14px"
|
|
2355
|
-
},
|
|
2356
|
-
children: showPassword ? "Hide" : "Show"
|
|
2357
|
-
}
|
|
2358
|
-
)
|
|
2359
|
-
] }),
|
|
2360
|
-
needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2361
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "otp", style: {
|
|
2362
|
-
display: "block",
|
|
2363
|
-
marginBottom: "8px",
|
|
2364
|
-
fontWeight: 500,
|
|
2365
|
-
color: "#374151",
|
|
2366
|
-
fontSize: "14px"
|
|
2367
|
-
}, children: "One-Time Password" }),
|
|
2368
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2369
|
-
"input",
|
|
2370
|
-
{
|
|
2371
|
-
id: "otp",
|
|
2372
|
-
type: "text",
|
|
2373
|
-
value: otp,
|
|
2374
|
-
onChange: (e) => setOtp(e.target.value),
|
|
2375
|
-
required: true,
|
|
2376
|
-
disabled: isLoading,
|
|
2377
|
-
maxLength: 6,
|
|
2378
|
-
style: {
|
|
2379
|
-
width: "100%",
|
|
2380
|
-
padding: "12px 16px",
|
|
2381
|
-
border: "1px solid #ddd",
|
|
2382
|
-
borderRadius: "8px",
|
|
2383
|
-
fontSize: "16px",
|
|
2384
|
-
boxSizing: "border-box",
|
|
2385
|
-
letterSpacing: "0.5em",
|
|
2386
|
-
textAlign: "center",
|
|
2387
|
-
...appearance?.elements?.formFieldInput
|
|
2388
|
-
},
|
|
2389
|
-
placeholder: "000000"
|
|
2390
|
-
}
|
|
2391
|
-
)
|
|
2392
|
-
] }),
|
|
2393
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2394
|
-
"button",
|
|
2395
|
-
{
|
|
2396
|
-
type: "submit",
|
|
2397
|
-
disabled: isLoading,
|
|
2398
|
-
style: {
|
|
2399
|
-
width: "100%",
|
|
2400
|
-
padding: "14px",
|
|
2401
|
-
backgroundColor: "#007bff",
|
|
2402
|
-
color: "white",
|
|
2403
|
-
border: "none",
|
|
2404
|
-
borderRadius: "8px",
|
|
2405
|
-
fontSize: "16px",
|
|
2687
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2688
|
+
ThemeWrapper,
|
|
2689
|
+
{
|
|
2690
|
+
style: {
|
|
2691
|
+
maxWidth: "400px",
|
|
2692
|
+
margin: "0 auto",
|
|
2693
|
+
padding: "30px",
|
|
2694
|
+
borderRadius: "12px",
|
|
2695
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
2696
|
+
backgroundColor: colors.bgPrimary,
|
|
2697
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2698
|
+
...appearance?.elements?.card
|
|
2699
|
+
},
|
|
2700
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
|
|
2701
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
2702
|
+
textAlign: "center",
|
|
2703
|
+
marginBottom: "24px",
|
|
2704
|
+
color: colors.textPrimary,
|
|
2705
|
+
fontSize: "24px",
|
|
2406
2706
|
fontWeight: 600,
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
fontSize: "14px"
|
|
2426
|
-
|
|
2427
|
-
},
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2707
|
+
...appearance?.elements?.headerTitle
|
|
2708
|
+
}, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
|
|
2709
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2710
|
+
padding: "12px 16px",
|
|
2711
|
+
marginBottom: "20px",
|
|
2712
|
+
backgroundColor: colors.errorBg,
|
|
2713
|
+
color: colors.errorText,
|
|
2714
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
2715
|
+
borderRadius: "8px",
|
|
2716
|
+
fontSize: "14px"
|
|
2717
|
+
}, children: error }),
|
|
2718
|
+
success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2719
|
+
padding: "12px 16px",
|
|
2720
|
+
marginBottom: "20px",
|
|
2721
|
+
backgroundColor: colors.successBg,
|
|
2722
|
+
color: colors.successText,
|
|
2723
|
+
border: `1px solid ${colors.successBorder}`,
|
|
2724
|
+
borderRadius: "8px",
|
|
2725
|
+
fontSize: "14px"
|
|
2726
|
+
}, children: success }),
|
|
2727
|
+
!needsOtp && !usePhone && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2728
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
|
|
2729
|
+
display: "block",
|
|
2730
|
+
marginBottom: "8px",
|
|
2731
|
+
fontWeight: 500,
|
|
2732
|
+
color: colors.textSecondary,
|
|
2733
|
+
fontSize: "14px"
|
|
2734
|
+
}, children: "Email" }),
|
|
2735
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2736
|
+
"input",
|
|
2737
|
+
{
|
|
2738
|
+
id: "email",
|
|
2739
|
+
type: "email",
|
|
2740
|
+
value: email,
|
|
2741
|
+
onChange: (e) => setEmail(e.target.value),
|
|
2742
|
+
onFocus: (e) => {
|
|
2743
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2744
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2745
|
+
},
|
|
2746
|
+
onBlur: (e) => {
|
|
2747
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2748
|
+
e.currentTarget.style.outline = "none";
|
|
2749
|
+
},
|
|
2750
|
+
required: true,
|
|
2751
|
+
disabled: isLoading,
|
|
2752
|
+
style: {
|
|
2753
|
+
width: "100%",
|
|
2754
|
+
padding: "12px 16px",
|
|
2755
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2756
|
+
borderRadius: "8px",
|
|
2757
|
+
fontSize: "16px",
|
|
2758
|
+
boxSizing: "border-box",
|
|
2759
|
+
backgroundColor: colors.bgSecondary,
|
|
2760
|
+
color: colors.textPrimary,
|
|
2761
|
+
transition: "all 0.2s ease",
|
|
2762
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2763
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2764
|
+
...appearance?.elements?.formFieldInput
|
|
2765
|
+
},
|
|
2766
|
+
placeholder: "Enter your email"
|
|
2767
|
+
}
|
|
2768
|
+
)
|
|
2769
|
+
] }),
|
|
2770
|
+
!needsOtp && usePhone && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2771
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
|
|
2772
|
+
display: "block",
|
|
2773
|
+
marginBottom: "8px",
|
|
2774
|
+
fontWeight: 500,
|
|
2775
|
+
color: colors.textSecondary,
|
|
2776
|
+
fontSize: "14px"
|
|
2777
|
+
}, children: "Phone Number" }),
|
|
2778
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2779
|
+
"input",
|
|
2780
|
+
{
|
|
2781
|
+
id: "phoneNumber",
|
|
2782
|
+
type: "tel",
|
|
2783
|
+
value: phoneNumber,
|
|
2784
|
+
onChange: (e) => setPhoneNumber(e.target.value),
|
|
2785
|
+
onFocus: (e) => {
|
|
2786
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2787
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2788
|
+
},
|
|
2789
|
+
onBlur: (e) => {
|
|
2790
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2791
|
+
e.currentTarget.style.outline = "none";
|
|
2792
|
+
},
|
|
2793
|
+
required: true,
|
|
2794
|
+
disabled: isLoading,
|
|
2795
|
+
style: {
|
|
2796
|
+
width: "100%",
|
|
2797
|
+
padding: "12px 16px",
|
|
2798
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2799
|
+
borderRadius: "8px",
|
|
2800
|
+
fontSize: "16px",
|
|
2801
|
+
boxSizing: "border-box",
|
|
2802
|
+
backgroundColor: colors.bgSecondary,
|
|
2803
|
+
color: colors.textPrimary,
|
|
2804
|
+
transition: "all 0.2s ease",
|
|
2805
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2806
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2807
|
+
...appearance?.elements?.formFieldInput
|
|
2808
|
+
},
|
|
2809
|
+
placeholder: "Enter your phone number"
|
|
2810
|
+
}
|
|
2811
|
+
)
|
|
2812
|
+
] }),
|
|
2813
|
+
usePassword && !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2814
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
|
|
2815
|
+
display: "block",
|
|
2816
|
+
marginBottom: "8px",
|
|
2817
|
+
fontWeight: 500,
|
|
2818
|
+
color: colors.textSecondary,
|
|
2819
|
+
fontSize: "14px"
|
|
2820
|
+
}, children: "Password" }),
|
|
2821
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2822
|
+
"input",
|
|
2823
|
+
{
|
|
2824
|
+
id: "password",
|
|
2825
|
+
type: showPassword ? "text" : "password",
|
|
2826
|
+
value: password,
|
|
2827
|
+
onChange: (e) => setPassword(e.target.value),
|
|
2828
|
+
onFocus: (e) => {
|
|
2829
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2830
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2831
|
+
},
|
|
2832
|
+
onBlur: (e) => {
|
|
2833
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2834
|
+
e.currentTarget.style.outline = "none";
|
|
2835
|
+
},
|
|
2836
|
+
required: true,
|
|
2837
|
+
disabled: isLoading,
|
|
2838
|
+
style: {
|
|
2839
|
+
width: "100%",
|
|
2840
|
+
padding: "12px 16px",
|
|
2841
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2842
|
+
borderRadius: "8px",
|
|
2843
|
+
fontSize: "16px",
|
|
2844
|
+
boxSizing: "border-box",
|
|
2845
|
+
backgroundColor: colors.bgSecondary,
|
|
2846
|
+
color: colors.textPrimary,
|
|
2847
|
+
transition: "all 0.2s ease",
|
|
2848
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2849
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2850
|
+
...appearance?.elements?.formFieldInput
|
|
2851
|
+
},
|
|
2852
|
+
placeholder: "Enter your password"
|
|
2853
|
+
}
|
|
2854
|
+
),
|
|
2855
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2856
|
+
"button",
|
|
2857
|
+
{
|
|
2858
|
+
type: "button",
|
|
2859
|
+
onClick: () => setShowPassword(!showPassword),
|
|
2860
|
+
style: {
|
|
2861
|
+
position: "absolute",
|
|
2862
|
+
right: "12px",
|
|
2863
|
+
top: "38px",
|
|
2864
|
+
background: "none",
|
|
2865
|
+
border: "none",
|
|
2866
|
+
cursor: "pointer",
|
|
2867
|
+
color: colors.textTertiary,
|
|
2868
|
+
fontSize: "14px"
|
|
2869
|
+
},
|
|
2870
|
+
children: showPassword ? "Hide" : "Show"
|
|
2871
|
+
}
|
|
2872
|
+
)
|
|
2873
|
+
] }),
|
|
2874
|
+
needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2875
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "otp", style: {
|
|
2876
|
+
display: "block",
|
|
2877
|
+
marginBottom: "8px",
|
|
2878
|
+
fontWeight: 500,
|
|
2879
|
+
color: colors.textSecondary,
|
|
2880
|
+
fontSize: "14px"
|
|
2881
|
+
}, children: "One-Time Password" }),
|
|
2882
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2883
|
+
"input",
|
|
2884
|
+
{
|
|
2885
|
+
id: "otp",
|
|
2886
|
+
type: "text",
|
|
2887
|
+
value: otp,
|
|
2888
|
+
onChange: (e) => setOtp(e.target.value),
|
|
2889
|
+
onFocus: (e) => {
|
|
2890
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2891
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2892
|
+
},
|
|
2893
|
+
onBlur: (e) => {
|
|
2894
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2895
|
+
e.currentTarget.style.outline = "none";
|
|
2896
|
+
},
|
|
2897
|
+
required: true,
|
|
2898
|
+
disabled: isLoading,
|
|
2899
|
+
maxLength: 6,
|
|
2900
|
+
style: {
|
|
2901
|
+
width: "100%",
|
|
2902
|
+
padding: "12px 16px",
|
|
2903
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2904
|
+
borderRadius: "8px",
|
|
2905
|
+
fontSize: "16px",
|
|
2906
|
+
boxSizing: "border-box",
|
|
2907
|
+
letterSpacing: "0.5em",
|
|
2908
|
+
textAlign: "center",
|
|
2909
|
+
backgroundColor: colors.bgSecondary,
|
|
2910
|
+
color: colors.textPrimary,
|
|
2911
|
+
transition: "all 0.2s ease",
|
|
2912
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2913
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2914
|
+
...appearance?.elements?.formFieldInput
|
|
2915
|
+
},
|
|
2916
|
+
placeholder: "000000"
|
|
2917
|
+
}
|
|
2918
|
+
)
|
|
2919
|
+
] }),
|
|
2920
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2921
|
+
"button",
|
|
2922
|
+
{
|
|
2923
|
+
type: "submit",
|
|
2924
|
+
disabled: isLoading,
|
|
2925
|
+
onMouseEnter: (e) => {
|
|
2926
|
+
if (!isLoading) {
|
|
2927
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
2928
|
+
}
|
|
2929
|
+
},
|
|
2930
|
+
onMouseLeave: (e) => {
|
|
2931
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
2932
|
+
},
|
|
2933
|
+
style: {
|
|
2934
|
+
width: "100%",
|
|
2935
|
+
padding: "14px",
|
|
2936
|
+
backgroundColor: colors.buttonPrimary,
|
|
2937
|
+
color: "white",
|
|
2938
|
+
border: "none",
|
|
2939
|
+
borderRadius: "8px",
|
|
2940
|
+
fontSize: "16px",
|
|
2941
|
+
fontWeight: 600,
|
|
2942
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
2943
|
+
opacity: isLoading ? 0.6 : 1,
|
|
2944
|
+
transition: "all 0.2s ease",
|
|
2945
|
+
...appearance?.elements?.formButtonPrimary
|
|
2946
|
+
},
|
|
2947
|
+
children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : usePhone ? "Continue with phone" : "Continue with email"
|
|
2948
|
+
}
|
|
2949
|
+
),
|
|
2950
|
+
!needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center", marginTop: "16px" }, children: [
|
|
2951
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2952
|
+
"button",
|
|
2953
|
+
{
|
|
2954
|
+
type: "button",
|
|
2955
|
+
onClick: toggleAuthMethod,
|
|
2956
|
+
disabled: isLoading,
|
|
2957
|
+
style: {
|
|
2958
|
+
background: "none",
|
|
2959
|
+
border: "none",
|
|
2960
|
+
color: colors.buttonPrimary,
|
|
2961
|
+
cursor: "pointer",
|
|
2962
|
+
fontSize: "14px",
|
|
2963
|
+
fontWeight: 600,
|
|
2964
|
+
marginRight: "16px"
|
|
2965
|
+
},
|
|
2966
|
+
children: usePassword ? "Use OTP code instead" : "Use password instead"
|
|
2967
|
+
}
|
|
2968
|
+
),
|
|
2969
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2970
|
+
"button",
|
|
2971
|
+
{
|
|
2972
|
+
type: "button",
|
|
2973
|
+
onClick: toggleLoginMethod,
|
|
2974
|
+
disabled: isLoading,
|
|
2975
|
+
style: {
|
|
2976
|
+
background: "none",
|
|
2977
|
+
border: "none",
|
|
2978
|
+
color: colors.buttonPrimary,
|
|
2979
|
+
cursor: "pointer",
|
|
2980
|
+
fontSize: "14px",
|
|
2981
|
+
fontWeight: 600
|
|
2982
|
+
},
|
|
2983
|
+
children: usePhone ? "Use email instead" : "Use phone instead"
|
|
2984
|
+
}
|
|
2985
|
+
)
|
|
2986
|
+
] }),
|
|
2987
|
+
needsOtp && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2988
|
+
"button",
|
|
2989
|
+
{
|
|
2990
|
+
type: "button",
|
|
2991
|
+
onClick: () => {
|
|
2992
|
+
setNeedsOtp(false);
|
|
2993
|
+
setOtp("");
|
|
2994
|
+
setError(null);
|
|
2995
|
+
setSuccess(null);
|
|
2996
|
+
},
|
|
2997
|
+
disabled: isLoading,
|
|
2998
|
+
style: {
|
|
2999
|
+
background: "none",
|
|
3000
|
+
border: "none",
|
|
3001
|
+
color: colors.buttonPrimary,
|
|
3002
|
+
cursor: "pointer",
|
|
3003
|
+
fontSize: "14px",
|
|
3004
|
+
fontWeight: 600
|
|
3005
|
+
},
|
|
3006
|
+
children: "Back to sign in"
|
|
3007
|
+
}
|
|
3008
|
+
) })
|
|
3009
|
+
] })
|
|
3010
|
+
}
|
|
3011
|
+
);
|
|
2454
3012
|
};
|
|
2455
3013
|
var SignUp = ({ redirectUrl, appearance }) => {
|
|
2456
3014
|
const { signUp, isSignedIn } = useAuth2();
|
|
2457
|
-
const
|
|
2458
|
-
const [
|
|
2459
|
-
const [
|
|
2460
|
-
const [
|
|
2461
|
-
const [
|
|
2462
|
-
const [
|
|
2463
|
-
const [
|
|
2464
|
-
const [
|
|
2465
|
-
|
|
3015
|
+
const colors = useThemeColors();
|
|
3016
|
+
const [name, setName] = React3.useState("");
|
|
3017
|
+
const [email, setEmail] = React3.useState("");
|
|
3018
|
+
const [phoneNumber, setPhoneNumber] = React3.useState("");
|
|
3019
|
+
const [password, setPassword] = React3.useState("");
|
|
3020
|
+
const [confirmPassword, setConfirmPassword] = React3.useState("");
|
|
3021
|
+
const [showPassword, setShowPassword] = React3.useState(false);
|
|
3022
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
3023
|
+
const [error, setError] = React3.useState(null);
|
|
3024
|
+
const [success, setSuccess] = React3.useState(null);
|
|
3025
|
+
React3.useEffect(() => {
|
|
2466
3026
|
if (isSignedIn && redirectUrl) {
|
|
2467
3027
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
|
|
2468
3028
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2469
3029
|
window.location.href = `${baseUrl}${redirect}`;
|
|
2470
3030
|
}
|
|
2471
3031
|
}, [isSignedIn, redirectUrl]);
|
|
2472
|
-
const getPasswordStrength = (pwd) => {
|
|
3032
|
+
const getPasswordStrength = (pwd, colors2) => {
|
|
2473
3033
|
if (!pwd)
|
|
2474
|
-
return { strength: "weak", color:
|
|
3034
|
+
return { strength: "weak", color: colors2.borderSecondary };
|
|
2475
3035
|
let score = 0;
|
|
2476
3036
|
if (pwd.length >= 6)
|
|
2477
3037
|
score++;
|
|
@@ -2484,12 +3044,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2484
3044
|
if (/[^a-zA-Z\d]/.test(pwd))
|
|
2485
3045
|
score++;
|
|
2486
3046
|
if (score <= 2)
|
|
2487
|
-
return { strength: "weak", color:
|
|
3047
|
+
return { strength: "weak", color: colors2.errorText };
|
|
2488
3048
|
if (score <= 3)
|
|
2489
|
-
return { strength: "medium", color: "#fa4" };
|
|
2490
|
-
return { strength: "strong", color:
|
|
3049
|
+
return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
3050
|
+
return { strength: "strong", color: colors2.successText };
|
|
2491
3051
|
};
|
|
2492
|
-
const passwordStrength = getPasswordStrength(password);
|
|
3052
|
+
const passwordStrength = getPasswordStrength(password, colors);
|
|
2493
3053
|
const handleSubmit = async (e) => {
|
|
2494
3054
|
e.preventDefault();
|
|
2495
3055
|
setIsLoading(true);
|
|
@@ -2506,7 +3066,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2506
3066
|
return;
|
|
2507
3067
|
}
|
|
2508
3068
|
try {
|
|
2509
|
-
const
|
|
3069
|
+
const signUpData = { name, password };
|
|
3070
|
+
if (email)
|
|
3071
|
+
signUpData.email = email;
|
|
3072
|
+
if (phoneNumber)
|
|
3073
|
+
signUpData.phoneNumber = phoneNumber;
|
|
3074
|
+
const response = await signUp(signUpData);
|
|
2510
3075
|
if (response.success) {
|
|
2511
3076
|
setSuccess("Registration successful! Please check your email to verify your account.");
|
|
2512
3077
|
} else {
|
|
@@ -2518,20 +3083,20 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2518
3083
|
setIsLoading(false);
|
|
2519
3084
|
}
|
|
2520
3085
|
};
|
|
2521
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3086
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ThemeWrapper, { style: {
|
|
2522
3087
|
maxWidth: "400px",
|
|
2523
3088
|
margin: "0 auto",
|
|
2524
3089
|
padding: "30px",
|
|
2525
3090
|
borderRadius: "12px",
|
|
2526
3091
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
2527
|
-
backgroundColor:
|
|
2528
|
-
border:
|
|
3092
|
+
backgroundColor: colors.bgPrimary,
|
|
3093
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2529
3094
|
...appearance?.elements?.card
|
|
2530
3095
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
|
|
2531
3096
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
2532
3097
|
textAlign: "center",
|
|
2533
3098
|
marginBottom: "24px",
|
|
2534
|
-
color:
|
|
3099
|
+
color: colors.textPrimary,
|
|
2535
3100
|
fontSize: "24px",
|
|
2536
3101
|
fontWeight: 600,
|
|
2537
3102
|
...appearance?.elements?.headerTitle
|
|
@@ -2539,18 +3104,18 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2539
3104
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2540
3105
|
padding: "12px 16px",
|
|
2541
3106
|
marginBottom: "20px",
|
|
2542
|
-
backgroundColor:
|
|
2543
|
-
color:
|
|
2544
|
-
border:
|
|
3107
|
+
backgroundColor: colors.errorBg,
|
|
3108
|
+
color: colors.errorText,
|
|
3109
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
2545
3110
|
borderRadius: "8px",
|
|
2546
3111
|
fontSize: "14px"
|
|
2547
3112
|
}, children: error }),
|
|
2548
3113
|
success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2549
3114
|
padding: "12px 16px",
|
|
2550
3115
|
marginBottom: "20px",
|
|
2551
|
-
backgroundColor:
|
|
2552
|
-
color:
|
|
2553
|
-
border:
|
|
3116
|
+
backgroundColor: colors.successBg,
|
|
3117
|
+
color: colors.successText,
|
|
3118
|
+
border: `1px solid ${colors.successBorder}`,
|
|
2554
3119
|
borderRadius: "8px",
|
|
2555
3120
|
fontSize: "14px"
|
|
2556
3121
|
}, children: success }),
|
|
@@ -2559,7 +3124,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2559
3124
|
display: "block",
|
|
2560
3125
|
marginBottom: "8px",
|
|
2561
3126
|
fontWeight: 500,
|
|
2562
|
-
color:
|
|
3127
|
+
color: colors.textSecondary,
|
|
2563
3128
|
fontSize: "14px"
|
|
2564
3129
|
}, children: "Full name" }),
|
|
2565
3130
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2569,15 +3134,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2569
3134
|
type: "text",
|
|
2570
3135
|
value: name,
|
|
2571
3136
|
onChange: (e) => setName(e.target.value),
|
|
3137
|
+
onFocus: (e) => {
|
|
3138
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3139
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3140
|
+
},
|
|
3141
|
+
onBlur: (e) => {
|
|
3142
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3143
|
+
e.currentTarget.style.outline = "none";
|
|
3144
|
+
},
|
|
2572
3145
|
required: true,
|
|
2573
3146
|
disabled: isLoading,
|
|
2574
3147
|
style: {
|
|
2575
3148
|
width: "100%",
|
|
2576
3149
|
padding: "12px 16px",
|
|
2577
|
-
border:
|
|
3150
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2578
3151
|
borderRadius: "8px",
|
|
2579
3152
|
fontSize: "16px",
|
|
2580
3153
|
boxSizing: "border-box",
|
|
3154
|
+
backgroundColor: colors.bgSecondary,
|
|
3155
|
+
color: colors.textPrimary,
|
|
3156
|
+
transition: "all 0.2s ease",
|
|
3157
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3158
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2581
3159
|
...appearance?.elements?.formFieldInput
|
|
2582
3160
|
},
|
|
2583
3161
|
placeholder: "Enter your full name"
|
|
@@ -2589,7 +3167,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2589
3167
|
display: "block",
|
|
2590
3168
|
marginBottom: "8px",
|
|
2591
3169
|
fontWeight: 500,
|
|
2592
|
-
color:
|
|
3170
|
+
color: colors.textSecondary,
|
|
2593
3171
|
fontSize: "14px"
|
|
2594
3172
|
}, children: "Email" }),
|
|
2595
3173
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2599,27 +3177,60 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2599
3177
|
type: "email",
|
|
2600
3178
|
value: email,
|
|
2601
3179
|
onChange: (e) => setEmail(e.target.value),
|
|
2602
|
-
|
|
3180
|
+
onFocus: (e) => {
|
|
3181
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3182
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3183
|
+
},
|
|
3184
|
+
onBlur: (e) => {
|
|
3185
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3186
|
+
e.currentTarget.style.outline = "none";
|
|
3187
|
+
},
|
|
3188
|
+
required: !phoneNumber,
|
|
2603
3189
|
disabled: isLoading,
|
|
2604
3190
|
style: {
|
|
2605
3191
|
width: "100%",
|
|
2606
3192
|
padding: "12px 16px",
|
|
2607
|
-
border:
|
|
3193
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2608
3194
|
borderRadius: "8px",
|
|
2609
3195
|
fontSize: "16px",
|
|
2610
3196
|
boxSizing: "border-box",
|
|
3197
|
+
backgroundColor: colors.bgSecondary,
|
|
3198
|
+
color: colors.textPrimary,
|
|
3199
|
+
transition: "all 0.2s ease",
|
|
3200
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3201
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2611
3202
|
...appearance?.elements?.formFieldInput
|
|
2612
3203
|
},
|
|
2613
3204
|
placeholder: "Enter your email"
|
|
2614
3205
|
}
|
|
2615
3206
|
)
|
|
2616
3207
|
] }),
|
|
3208
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
3209
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
|
|
3210
|
+
display: "block",
|
|
3211
|
+
marginBottom: "8px",
|
|
3212
|
+
fontWeight: 500,
|
|
3213
|
+
color: colors.textSecondary,
|
|
3214
|
+
fontSize: "14px"
|
|
3215
|
+
}, children: "Phone Number (Optional)" }),
|
|
3216
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3217
|
+
PhoneInput,
|
|
3218
|
+
{
|
|
3219
|
+
id: "phoneNumber",
|
|
3220
|
+
value: phoneNumber,
|
|
3221
|
+
onChange: setPhoneNumber,
|
|
3222
|
+
disabled: isLoading,
|
|
3223
|
+
placeholder: "1234567890",
|
|
3224
|
+
style: appearance?.elements?.formFieldInput
|
|
3225
|
+
}
|
|
3226
|
+
)
|
|
3227
|
+
] }),
|
|
2617
3228
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2618
3229
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
|
|
2619
3230
|
display: "block",
|
|
2620
3231
|
marginBottom: "8px",
|
|
2621
3232
|
fontWeight: 500,
|
|
2622
|
-
color:
|
|
3233
|
+
color: colors.textSecondary,
|
|
2623
3234
|
fontSize: "14px"
|
|
2624
3235
|
}, children: "Password" }),
|
|
2625
3236
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2629,16 +3240,29 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2629
3240
|
type: showPassword ? "text" : "password",
|
|
2630
3241
|
value: password,
|
|
2631
3242
|
onChange: (e) => setPassword(e.target.value),
|
|
3243
|
+
onFocus: (e) => {
|
|
3244
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3245
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3246
|
+
},
|
|
3247
|
+
onBlur: (e) => {
|
|
3248
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3249
|
+
e.currentTarget.style.outline = "none";
|
|
3250
|
+
},
|
|
2632
3251
|
required: true,
|
|
2633
3252
|
disabled: isLoading,
|
|
2634
3253
|
minLength: 6,
|
|
2635
3254
|
style: {
|
|
2636
3255
|
width: "100%",
|
|
2637
3256
|
padding: "12px 16px",
|
|
2638
|
-
border:
|
|
3257
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2639
3258
|
borderRadius: "8px",
|
|
2640
3259
|
fontSize: "16px",
|
|
2641
3260
|
boxSizing: "border-box",
|
|
3261
|
+
backgroundColor: colors.bgSecondary,
|
|
3262
|
+
color: colors.textPrimary,
|
|
3263
|
+
transition: "all 0.2s ease",
|
|
3264
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3265
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2642
3266
|
...appearance?.elements?.formFieldInput
|
|
2643
3267
|
},
|
|
2644
3268
|
placeholder: "Create a password"
|
|
@@ -2656,7 +3280,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2656
3280
|
background: "none",
|
|
2657
3281
|
border: "none",
|
|
2658
3282
|
cursor: "pointer",
|
|
2659
|
-
color:
|
|
3283
|
+
color: colors.textTertiary,
|
|
2660
3284
|
fontSize: "14px"
|
|
2661
3285
|
},
|
|
2662
3286
|
children: showPassword ? "Hide" : "Show"
|
|
@@ -2665,7 +3289,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2665
3289
|
password && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "8px" }, children: [
|
|
2666
3290
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2667
3291
|
height: "4px",
|
|
2668
|
-
backgroundColor:
|
|
3292
|
+
backgroundColor: colors.borderSecondary,
|
|
2669
3293
|
borderRadius: "2px",
|
|
2670
3294
|
overflow: "hidden"
|
|
2671
3295
|
}, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
@@ -2690,7 +3314,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2690
3314
|
display: "block",
|
|
2691
3315
|
marginBottom: "8px",
|
|
2692
3316
|
fontWeight: 500,
|
|
2693
|
-
color:
|
|
3317
|
+
color: colors.textSecondary,
|
|
2694
3318
|
fontSize: "14px"
|
|
2695
3319
|
}, children: "Confirm password" }),
|
|
2696
3320
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2700,15 +3324,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2700
3324
|
type: showPassword ? "text" : "password",
|
|
2701
3325
|
value: confirmPassword,
|
|
2702
3326
|
onChange: (e) => setConfirmPassword(e.target.value),
|
|
3327
|
+
onFocus: (e) => {
|
|
3328
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3329
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3330
|
+
},
|
|
3331
|
+
onBlur: (e) => {
|
|
3332
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3333
|
+
e.currentTarget.style.outline = "none";
|
|
3334
|
+
},
|
|
2703
3335
|
required: true,
|
|
2704
3336
|
disabled: isLoading,
|
|
2705
3337
|
style: {
|
|
2706
3338
|
width: "100%",
|
|
2707
3339
|
padding: "12px 16px",
|
|
2708
|
-
border:
|
|
3340
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2709
3341
|
borderRadius: "8px",
|
|
2710
3342
|
fontSize: "16px",
|
|
2711
3343
|
boxSizing: "border-box",
|
|
3344
|
+
backgroundColor: colors.bgSecondary,
|
|
3345
|
+
color: colors.textPrimary,
|
|
3346
|
+
transition: "all 0.2s ease",
|
|
3347
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3348
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2712
3349
|
...appearance?.elements?.formFieldInput
|
|
2713
3350
|
},
|
|
2714
3351
|
placeholder: "Confirm your password"
|
|
@@ -2720,16 +3357,25 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2720
3357
|
{
|
|
2721
3358
|
type: "submit",
|
|
2722
3359
|
disabled: isLoading,
|
|
3360
|
+
onMouseEnter: (e) => {
|
|
3361
|
+
if (!isLoading) {
|
|
3362
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
3363
|
+
}
|
|
3364
|
+
},
|
|
3365
|
+
onMouseLeave: (e) => {
|
|
3366
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
3367
|
+
},
|
|
2723
3368
|
style: {
|
|
2724
3369
|
width: "100%",
|
|
2725
3370
|
padding: "14px",
|
|
2726
|
-
backgroundColor:
|
|
3371
|
+
backgroundColor: colors.buttonPrimary,
|
|
2727
3372
|
color: "white",
|
|
2728
3373
|
border: "none",
|
|
2729
3374
|
borderRadius: "8px",
|
|
2730
3375
|
fontSize: "16px",
|
|
2731
3376
|
fontWeight: 600,
|
|
2732
|
-
cursor: "pointer",
|
|
3377
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
3378
|
+
opacity: isLoading ? 0.6 : 1,
|
|
2733
3379
|
transition: "all 0.2s ease",
|
|
2734
3380
|
...appearance?.elements?.formButtonPrimary
|
|
2735
3381
|
},
|
|
@@ -2740,7 +3386,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2740
3386
|
};
|
|
2741
3387
|
var SignOut = ({ redirectUrl }) => {
|
|
2742
3388
|
const { signOut } = useAuth2();
|
|
2743
|
-
|
|
3389
|
+
React3.useEffect(() => {
|
|
2744
3390
|
const performSignOut = async () => {
|
|
2745
3391
|
await signOut();
|
|
2746
3392
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
|
|
@@ -2753,9 +3399,10 @@ var SignOut = ({ redirectUrl }) => {
|
|
|
2753
3399
|
};
|
|
2754
3400
|
var UserButton = ({ showName = false, appearance }) => {
|
|
2755
3401
|
const { user, signOut } = useAuth2();
|
|
2756
|
-
const
|
|
2757
|
-
const
|
|
2758
|
-
|
|
3402
|
+
const colors = useThemeColors();
|
|
3403
|
+
const [isOpen, setIsOpen] = React3.useState(false);
|
|
3404
|
+
const dropdownRef = React3.useRef(null);
|
|
3405
|
+
React3.useEffect(() => {
|
|
2759
3406
|
const handleClickOutside = (event) => {
|
|
2760
3407
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
2761
3408
|
setIsOpen(false);
|
|
@@ -2775,7 +3422,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2775
3422
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2776
3423
|
window.location.href = `${baseUrl}${redirect}`;
|
|
2777
3424
|
};
|
|
2778
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3425
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ThemeWrapper, { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
|
|
2779
3426
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2780
3427
|
"button",
|
|
2781
3428
|
{
|
|
@@ -2793,7 +3440,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2793
3440
|
...appearance?.elements?.userButtonTrigger
|
|
2794
3441
|
},
|
|
2795
3442
|
onMouseEnter: (e) => {
|
|
2796
|
-
e.currentTarget.style.backgroundColor =
|
|
3443
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2797
3444
|
},
|
|
2798
3445
|
onMouseLeave: (e) => {
|
|
2799
3446
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
@@ -2803,15 +3450,15 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2803
3450
|
width: "36px",
|
|
2804
3451
|
height: "36px",
|
|
2805
3452
|
borderRadius: "50%",
|
|
2806
|
-
backgroundColor:
|
|
2807
|
-
color:
|
|
3453
|
+
backgroundColor: colors.buttonPrimary,
|
|
3454
|
+
color: colors.textPrimary,
|
|
2808
3455
|
display: "flex",
|
|
2809
3456
|
alignItems: "center",
|
|
2810
3457
|
justifyContent: "center",
|
|
2811
3458
|
fontSize: "14px",
|
|
2812
3459
|
fontWeight: 600
|
|
2813
3460
|
}, children: getInitials(user.name) }),
|
|
2814
|
-
showName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "14px", fontWeight: 500, color:
|
|
3461
|
+
showName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: colors.textPrimary }, children: user.name })
|
|
2815
3462
|
]
|
|
2816
3463
|
}
|
|
2817
3464
|
),
|
|
@@ -2821,16 +3468,16 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2821
3468
|
right: 0,
|
|
2822
3469
|
marginTop: "8px",
|
|
2823
3470
|
width: "240px",
|
|
2824
|
-
backgroundColor:
|
|
3471
|
+
backgroundColor: colors.bgPrimary,
|
|
2825
3472
|
borderRadius: "12px",
|
|
2826
3473
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
|
|
2827
|
-
border:
|
|
3474
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2828
3475
|
zIndex: 1e3,
|
|
2829
3476
|
...appearance?.elements?.userButtonPopoverCard
|
|
2830
3477
|
}, children: [
|
|
2831
3478
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2832
3479
|
padding: "16px",
|
|
2833
|
-
borderBottom:
|
|
3480
|
+
borderBottom: `1px solid ${colors.borderPrimary}`
|
|
2834
3481
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
2835
3482
|
display: "flex",
|
|
2836
3483
|
alignItems: "center",
|
|
@@ -2840,8 +3487,8 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2840
3487
|
width: "48px",
|
|
2841
3488
|
height: "48px",
|
|
2842
3489
|
borderRadius: "50%",
|
|
2843
|
-
backgroundColor:
|
|
2844
|
-
color:
|
|
3490
|
+
backgroundColor: colors.buttonPrimary,
|
|
3491
|
+
color: colors.textPrimary,
|
|
2845
3492
|
display: "flex",
|
|
2846
3493
|
alignItems: "center",
|
|
2847
3494
|
justifyContent: "center",
|
|
@@ -2852,14 +3499,14 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2852
3499
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2853
3500
|
fontSize: "14px",
|
|
2854
3501
|
fontWeight: 600,
|
|
2855
|
-
color:
|
|
3502
|
+
color: colors.textPrimary,
|
|
2856
3503
|
overflow: "hidden",
|
|
2857
3504
|
textOverflow: "ellipsis",
|
|
2858
3505
|
whiteSpace: "nowrap"
|
|
2859
3506
|
}, children: user.name }),
|
|
2860
3507
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2861
3508
|
fontSize: "12px",
|
|
2862
|
-
color:
|
|
3509
|
+
color: colors.textTertiary,
|
|
2863
3510
|
overflow: "hidden",
|
|
2864
3511
|
textOverflow: "ellipsis",
|
|
2865
3512
|
whiteSpace: "nowrap"
|
|
@@ -2879,12 +3526,12 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2879
3526
|
textAlign: "left",
|
|
2880
3527
|
cursor: "pointer",
|
|
2881
3528
|
fontSize: "14px",
|
|
2882
|
-
color:
|
|
3529
|
+
color: colors.textPrimary,
|
|
2883
3530
|
fontWeight: 500,
|
|
2884
3531
|
transition: "background-color 0.2s"
|
|
2885
3532
|
},
|
|
2886
3533
|
onMouseEnter: (e) => {
|
|
2887
|
-
e.currentTarget.style.backgroundColor =
|
|
3534
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2888
3535
|
},
|
|
2889
3536
|
onMouseLeave: (e) => {
|
|
2890
3537
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
@@ -2901,7 +3548,7 @@ var ProtectedRoute = ({
|
|
|
2901
3548
|
redirectTo
|
|
2902
3549
|
}) => {
|
|
2903
3550
|
const { isSignedIn, isLoaded } = useAuth2();
|
|
2904
|
-
|
|
3551
|
+
React3.useEffect(() => {
|
|
2905
3552
|
if (isLoaded && !isSignedIn) {
|
|
2906
3553
|
const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
|
|
2907
3554
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -2926,7 +3573,7 @@ var PublicRoute = ({
|
|
|
2926
3573
|
redirectTo
|
|
2927
3574
|
}) => {
|
|
2928
3575
|
const { isSignedIn, isLoaded } = useAuth2();
|
|
2929
|
-
|
|
3576
|
+
React3.useEffect(() => {
|
|
2930
3577
|
if (isLoaded && isSignedIn) {
|
|
2931
3578
|
const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
2932
3579
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -2948,9 +3595,9 @@ var PublicRoute = ({
|
|
|
2948
3595
|
};
|
|
2949
3596
|
var VerifyEmail = ({ token, onSuccess, onError }) => {
|
|
2950
3597
|
const { verifyEmailToken } = useAuth2();
|
|
2951
|
-
const [status, setStatus] =
|
|
2952
|
-
const [message, setMessage] =
|
|
2953
|
-
|
|
3598
|
+
const [status, setStatus] = React3.useState("loading");
|
|
3599
|
+
const [message, setMessage] = React3.useState("");
|
|
3600
|
+
React3.useEffect(() => {
|
|
2954
3601
|
const verify = async () => {
|
|
2955
3602
|
const verifyToken = token || (typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("token") : null);
|
|
2956
3603
|
if (!verifyToken) {
|
|
@@ -3084,10 +3731,10 @@ var VerifyEmail = ({ token, onSuccess, onError }) => {
|
|
|
3084
3731
|
};
|
|
3085
3732
|
var ForgotPassword = ({ appearance }) => {
|
|
3086
3733
|
const { forgotPassword } = useAuth2();
|
|
3087
|
-
const [email, setEmail] =
|
|
3088
|
-
const [isLoading, setIsLoading] =
|
|
3089
|
-
const [error, setError] =
|
|
3090
|
-
const [success, setSuccess] =
|
|
3734
|
+
const [email, setEmail] = React3.useState("");
|
|
3735
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
3736
|
+
const [error, setError] = React3.useState(null);
|
|
3737
|
+
const [success, setSuccess] = React3.useState(null);
|
|
3091
3738
|
const handleSubmit = async (e) => {
|
|
3092
3739
|
e.preventDefault();
|
|
3093
3740
|
setIsLoading(true);
|
|
@@ -3226,14 +3873,14 @@ var ForgotPassword = ({ appearance }) => {
|
|
|
3226
3873
|
};
|
|
3227
3874
|
var ResetPassword = ({ token, appearance }) => {
|
|
3228
3875
|
const { resetPassword } = useAuth2();
|
|
3229
|
-
const [resetToken, setResetToken] =
|
|
3230
|
-
const [password, setPassword] =
|
|
3231
|
-
const [confirmPassword, setConfirmPassword] =
|
|
3232
|
-
const [showPassword, setShowPassword] =
|
|
3233
|
-
const [isLoading, setIsLoading] =
|
|
3234
|
-
const [error, setError] =
|
|
3235
|
-
const [success, setSuccess] =
|
|
3236
|
-
|
|
3876
|
+
const [resetToken, setResetToken] = React3.useState(token || "");
|
|
3877
|
+
const [password, setPassword] = React3.useState("");
|
|
3878
|
+
const [confirmPassword, setConfirmPassword] = React3.useState("");
|
|
3879
|
+
const [showPassword, setShowPassword] = React3.useState(false);
|
|
3880
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
3881
|
+
const [error, setError] = React3.useState(null);
|
|
3882
|
+
const [success, setSuccess] = React3.useState(false);
|
|
3883
|
+
React3.useEffect(() => {
|
|
3237
3884
|
if (!resetToken && typeof window !== "undefined") {
|
|
3238
3885
|
const urlToken = new URLSearchParams(window.location.search).get("token");
|
|
3239
3886
|
if (urlToken) {
|
|
@@ -3488,13 +4135,13 @@ var ResetPassword = ({ token, appearance }) => {
|
|
|
3488
4135
|
};
|
|
3489
4136
|
var ChangePassword = ({ onSuccess, appearance }) => {
|
|
3490
4137
|
const { changePassword } = useAuth2();
|
|
3491
|
-
const [oldPassword, setOldPassword] =
|
|
3492
|
-
const [newPassword, setNewPassword] =
|
|
3493
|
-
const [confirmPassword, setConfirmPassword] =
|
|
3494
|
-
const [showPasswords, setShowPasswords] =
|
|
3495
|
-
const [isLoading, setIsLoading] =
|
|
3496
|
-
const [error, setError] =
|
|
3497
|
-
const [success, setSuccess] =
|
|
4138
|
+
const [oldPassword, setOldPassword] = React3.useState("");
|
|
4139
|
+
const [newPassword, setNewPassword] = React3.useState("");
|
|
4140
|
+
const [confirmPassword, setConfirmPassword] = React3.useState("");
|
|
4141
|
+
const [showPasswords, setShowPasswords] = React3.useState(false);
|
|
4142
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
4143
|
+
const [error, setError] = React3.useState(null);
|
|
4144
|
+
const [success, setSuccess] = React3.useState(false);
|
|
3498
4145
|
const getPasswordStrength = (pwd) => {
|
|
3499
4146
|
if (!pwd)
|
|
3500
4147
|
return { strength: "weak", color: "#ddd" };
|
|
@@ -3737,43 +4384,41 @@ var UserProfile = ({
|
|
|
3737
4384
|
showEmailChange = true,
|
|
3738
4385
|
showPasswordChange = true
|
|
3739
4386
|
}) => {
|
|
3740
|
-
const { user, updateProfile,
|
|
3741
|
-
const
|
|
3742
|
-
const [
|
|
3743
|
-
const [
|
|
3744
|
-
const [
|
|
3745
|
-
const [
|
|
3746
|
-
const [
|
|
3747
|
-
const
|
|
4387
|
+
const { user, updateProfile, requestEmailChange } = useAuth2();
|
|
4388
|
+
const colors = useThemeColors();
|
|
4389
|
+
const [name, setName] = React3.useState(user?.name || "");
|
|
4390
|
+
const [avatar, setAvatar] = React3.useState(user?.avatar || "");
|
|
4391
|
+
const [phoneNumber, setPhoneNumber] = React3.useState(user?.phoneNumber || "");
|
|
4392
|
+
const [newEmail, setNewEmail] = React3.useState("");
|
|
4393
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
4394
|
+
const [error, setError] = React3.useState(null);
|
|
4395
|
+
const [success, setSuccess] = React3.useState(null);
|
|
4396
|
+
const handleUpdateProfile = async (e) => {
|
|
3748
4397
|
e.preventDefault();
|
|
3749
4398
|
setIsLoading(true);
|
|
3750
4399
|
setError(null);
|
|
3751
4400
|
setSuccess(null);
|
|
3752
4401
|
try {
|
|
3753
|
-
const
|
|
3754
|
-
if (
|
|
3755
|
-
|
|
3756
|
-
} else {
|
|
3757
|
-
setError(response.message || "Failed to update name");
|
|
4402
|
+
const updates = {};
|
|
4403
|
+
if (name !== user?.name) {
|
|
4404
|
+
updates.name = name;
|
|
3758
4405
|
}
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
const response = await updateAvatar(avatar);
|
|
4406
|
+
if (showAvatar && avatar !== user?.avatar) {
|
|
4407
|
+
updates.avatar = avatar;
|
|
4408
|
+
}
|
|
4409
|
+
if (phoneNumber !== user?.phoneNumber) {
|
|
4410
|
+
updates.phoneNumber = phoneNumber;
|
|
4411
|
+
}
|
|
4412
|
+
if (Object.keys(updates).length === 0) {
|
|
4413
|
+
setError("No changes to save");
|
|
4414
|
+
setIsLoading(false);
|
|
4415
|
+
return;
|
|
4416
|
+
}
|
|
4417
|
+
const response = await updateProfile(updates);
|
|
3772
4418
|
if (response.success) {
|
|
3773
|
-
setSuccess("
|
|
3774
|
-
setAvatar("");
|
|
4419
|
+
setSuccess("Profile updated successfully!");
|
|
3775
4420
|
} else {
|
|
3776
|
-
setError(response.message || "Failed to update
|
|
4421
|
+
setError(response.message || "Failed to update profile");
|
|
3777
4422
|
}
|
|
3778
4423
|
} catch (err) {
|
|
3779
4424
|
setError(err instanceof Error ? err.message : "An error occurred");
|
|
@@ -3802,173 +4447,220 @@ var UserProfile = ({
|
|
|
3802
4447
|
};
|
|
3803
4448
|
if (!user)
|
|
3804
4449
|
return null;
|
|
3805
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "
|
|
3806
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600 }, children: "Profile Settings" }),
|
|
4450
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
|
|
4451
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
|
|
3807
4452
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
3808
4453
|
padding: "12px 16px",
|
|
3809
4454
|
marginBottom: "20px",
|
|
3810
|
-
backgroundColor:
|
|
3811
|
-
color:
|
|
3812
|
-
border:
|
|
4455
|
+
backgroundColor: colors.errorBg,
|
|
4456
|
+
color: colors.errorText,
|
|
4457
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
3813
4458
|
borderRadius: "8px",
|
|
3814
4459
|
fontSize: "14px"
|
|
3815
4460
|
}, children: error }),
|
|
3816
4461
|
success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
3817
4462
|
padding: "12px 16px",
|
|
3818
4463
|
marginBottom: "20px",
|
|
3819
|
-
backgroundColor:
|
|
3820
|
-
color:
|
|
3821
|
-
border:
|
|
4464
|
+
backgroundColor: colors.successBg,
|
|
4465
|
+
color: colors.successText,
|
|
4466
|
+
border: `1px solid ${colors.successBorder}`,
|
|
3822
4467
|
borderRadius: "8px",
|
|
3823
4468
|
fontSize: "14px"
|
|
3824
4469
|
}, children: success }),
|
|
3825
4470
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
3826
|
-
padding: "
|
|
3827
|
-
backgroundColor:
|
|
3828
|
-
borderRadius: "
|
|
4471
|
+
padding: "24px",
|
|
4472
|
+
backgroundColor: colors.bgPrimary,
|
|
4473
|
+
borderRadius: "12px",
|
|
3829
4474
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3830
|
-
marginBottom: "
|
|
4475
|
+
marginBottom: "24px",
|
|
4476
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
3831
4477
|
}, children: [
|
|
3832
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "
|
|
3833
|
-
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit:
|
|
3834
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3835
|
-
"
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
4478
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "20px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Information" }),
|
|
4479
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleUpdateProfile, children: [
|
|
4480
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
4481
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "name", style: {
|
|
4482
|
+
display: "block",
|
|
4483
|
+
marginBottom: "8px",
|
|
4484
|
+
fontWeight: 500,
|
|
4485
|
+
color: colors.textSecondary,
|
|
4486
|
+
fontSize: "14px"
|
|
4487
|
+
}, children: "Full Name" }),
|
|
4488
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4489
|
+
"input",
|
|
4490
|
+
{
|
|
4491
|
+
id: "name",
|
|
4492
|
+
type: "text",
|
|
4493
|
+
value: name,
|
|
4494
|
+
onChange: (e) => setName(e.target.value),
|
|
4495
|
+
required: true,
|
|
4496
|
+
disabled: isLoading,
|
|
4497
|
+
style: {
|
|
4498
|
+
width: "100%",
|
|
4499
|
+
padding: "12px 16px",
|
|
4500
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
4501
|
+
borderRadius: "8px",
|
|
4502
|
+
fontSize: "16px",
|
|
4503
|
+
boxSizing: "border-box",
|
|
4504
|
+
backgroundColor: colors.bgSecondary,
|
|
4505
|
+
color: colors.textPrimary,
|
|
4506
|
+
transition: "all 0.2s ease"
|
|
4507
|
+
},
|
|
4508
|
+
placeholder: "Manish Batra"
|
|
4509
|
+
}
|
|
4510
|
+
)
|
|
4511
|
+
] }),
|
|
4512
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
4513
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
|
|
4514
|
+
display: "block",
|
|
4515
|
+
marginBottom: "8px",
|
|
4516
|
+
fontWeight: 500,
|
|
4517
|
+
color: colors.textSecondary,
|
|
4518
|
+
fontSize: "14px"
|
|
4519
|
+
}, children: "Phone Number" }),
|
|
4520
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4521
|
+
PhoneInput,
|
|
4522
|
+
{
|
|
4523
|
+
id: "phoneNumber",
|
|
4524
|
+
value: phoneNumber,
|
|
4525
|
+
onChange: setPhoneNumber,
|
|
4526
|
+
disabled: isLoading,
|
|
4527
|
+
placeholder: "1234567890"
|
|
4528
|
+
}
|
|
4529
|
+
)
|
|
4530
|
+
] }),
|
|
4531
|
+
showAvatar && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
4532
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "avatar", style: {
|
|
4533
|
+
display: "block",
|
|
4534
|
+
marginBottom: "8px",
|
|
4535
|
+
fontWeight: 500,
|
|
4536
|
+
color: colors.textSecondary,
|
|
4537
|
+
fontSize: "14px"
|
|
4538
|
+
}, children: "Avatar URL" }),
|
|
4539
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4540
|
+
"input",
|
|
4541
|
+
{
|
|
4542
|
+
id: "avatar",
|
|
4543
|
+
type: "url",
|
|
4544
|
+
value: avatar,
|
|
4545
|
+
onChange: (e) => setAvatar(e.target.value),
|
|
4546
|
+
disabled: isLoading,
|
|
4547
|
+
style: {
|
|
4548
|
+
width: "100%",
|
|
4549
|
+
padding: "12px 16px",
|
|
4550
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
4551
|
+
borderRadius: "8px",
|
|
4552
|
+
fontSize: "16px",
|
|
4553
|
+
boxSizing: "border-box",
|
|
4554
|
+
backgroundColor: colors.bgSecondary,
|
|
4555
|
+
color: colors.textPrimary,
|
|
4556
|
+
transition: "all 0.2s ease"
|
|
4557
|
+
},
|
|
4558
|
+
placeholder: "https://example.com/avatar.jpg"
|
|
4559
|
+
}
|
|
4560
|
+
)
|
|
4561
|
+
] }),
|
|
3854
4562
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3855
4563
|
"button",
|
|
3856
4564
|
{
|
|
3857
4565
|
type: "submit",
|
|
3858
4566
|
disabled: isLoading,
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
border: "none",
|
|
3864
|
-
borderRadius: "8px",
|
|
3865
|
-
fontSize: "14px",
|
|
3866
|
-
fontWeight: 600,
|
|
3867
|
-
cursor: "pointer"
|
|
4567
|
+
onMouseEnter: (e) => {
|
|
4568
|
+
if (!isLoading) {
|
|
4569
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
4570
|
+
}
|
|
3868
4571
|
},
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
)
|
|
3872
|
-
] })
|
|
3873
|
-
] }),
|
|
3874
|
-
showAvatar && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
3875
|
-
padding: "20px",
|
|
3876
|
-
backgroundColor: "#fff",
|
|
3877
|
-
borderRadius: "8px",
|
|
3878
|
-
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3879
|
-
marginBottom: "20px"
|
|
3880
|
-
}, children: [
|
|
3881
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Avatar" }),
|
|
3882
|
-
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleUpdateAvatar, children: [
|
|
3883
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3884
|
-
"input",
|
|
3885
|
-
{
|
|
3886
|
-
type: "url",
|
|
3887
|
-
value: avatar,
|
|
3888
|
-
onChange: (e) => setAvatar(e.target.value),
|
|
3889
|
-
required: true,
|
|
3890
|
-
disabled: isLoading,
|
|
3891
|
-
style: {
|
|
3892
|
-
width: "100%",
|
|
3893
|
-
padding: "12px 16px",
|
|
3894
|
-
border: "1px solid #ddd",
|
|
3895
|
-
borderRadius: "8px",
|
|
3896
|
-
fontSize: "16px",
|
|
3897
|
-
boxSizing: "border-box",
|
|
3898
|
-
marginBottom: "12px"
|
|
4572
|
+
onMouseLeave: (e) => {
|
|
4573
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
3899
4574
|
},
|
|
3900
|
-
placeholder: "Avatar URL"
|
|
3901
|
-
}
|
|
3902
|
-
),
|
|
3903
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3904
|
-
"button",
|
|
3905
|
-
{
|
|
3906
|
-
type: "submit",
|
|
3907
|
-
disabled: isLoading,
|
|
3908
4575
|
style: {
|
|
3909
|
-
padding: "
|
|
3910
|
-
backgroundColor:
|
|
4576
|
+
padding: "12px 24px",
|
|
4577
|
+
backgroundColor: colors.buttonPrimary,
|
|
3911
4578
|
color: "white",
|
|
3912
4579
|
border: "none",
|
|
3913
4580
|
borderRadius: "8px",
|
|
3914
4581
|
fontSize: "14px",
|
|
3915
4582
|
fontWeight: 600,
|
|
3916
|
-
cursor: "pointer"
|
|
4583
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
4584
|
+
opacity: isLoading ? 0.6 : 1,
|
|
4585
|
+
transition: "all 0.2s ease"
|
|
3917
4586
|
},
|
|
3918
|
-
children: "
|
|
4587
|
+
children: isLoading ? "Saving..." : "Save Changes"
|
|
3919
4588
|
}
|
|
3920
4589
|
)
|
|
3921
4590
|
] })
|
|
3922
4591
|
] }),
|
|
3923
4592
|
showEmailChange && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
3924
|
-
padding: "
|
|
3925
|
-
backgroundColor:
|
|
3926
|
-
borderRadius: "
|
|
4593
|
+
padding: "24px",
|
|
4594
|
+
backgroundColor: colors.bgPrimary,
|
|
4595
|
+
borderRadius: "12px",
|
|
3927
4596
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3928
|
-
marginBottom: "20px"
|
|
4597
|
+
marginBottom: "20px",
|
|
4598
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
3929
4599
|
}, children: [
|
|
3930
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Change Email" }),
|
|
3931
|
-
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: { fontSize: "14px", color:
|
|
4600
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Change Email" }),
|
|
4601
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: { fontSize: "14px", color: colors.textSecondary, marginBottom: "16px" }, children: [
|
|
3932
4602
|
"Current email: ",
|
|
3933
4603
|
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: user.email })
|
|
3934
4604
|
] }),
|
|
3935
4605
|
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleRequestEmailChange, children: [
|
|
3936
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3937
|
-
"
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
4606
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "16px" }, children: [
|
|
4607
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "newEmail", style: {
|
|
4608
|
+
display: "block",
|
|
4609
|
+
marginBottom: "8px",
|
|
4610
|
+
fontWeight: 500,
|
|
4611
|
+
color: colors.textSecondary,
|
|
4612
|
+
fontSize: "14px"
|
|
4613
|
+
}, children: "New Email Address" }),
|
|
4614
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4615
|
+
"input",
|
|
4616
|
+
{
|
|
4617
|
+
id: "newEmail",
|
|
4618
|
+
type: "email",
|
|
4619
|
+
value: newEmail,
|
|
4620
|
+
onChange: (e) => setNewEmail(e.target.value),
|
|
4621
|
+
required: true,
|
|
4622
|
+
disabled: isLoading,
|
|
4623
|
+
style: {
|
|
4624
|
+
width: "100%",
|
|
4625
|
+
padding: "12px 16px",
|
|
4626
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
4627
|
+
borderRadius: "8px",
|
|
4628
|
+
fontSize: "16px",
|
|
4629
|
+
boxSizing: "border-box",
|
|
4630
|
+
backgroundColor: colors.bgSecondary,
|
|
4631
|
+
color: colors.textPrimary,
|
|
4632
|
+
transition: "all 0.2s ease"
|
|
4633
|
+
},
|
|
4634
|
+
placeholder: "newemail@example.com"
|
|
4635
|
+
}
|
|
4636
|
+
)
|
|
4637
|
+
] }),
|
|
3956
4638
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3957
4639
|
"button",
|
|
3958
4640
|
{
|
|
3959
4641
|
type: "submit",
|
|
3960
4642
|
disabled: isLoading,
|
|
4643
|
+
onMouseEnter: (e) => {
|
|
4644
|
+
if (!isLoading) {
|
|
4645
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
4646
|
+
}
|
|
4647
|
+
},
|
|
4648
|
+
onMouseLeave: (e) => {
|
|
4649
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
4650
|
+
},
|
|
3961
4651
|
style: {
|
|
3962
|
-
padding: "
|
|
3963
|
-
backgroundColor:
|
|
4652
|
+
padding: "12px 24px",
|
|
4653
|
+
backgroundColor: colors.buttonPrimary,
|
|
3964
4654
|
color: "white",
|
|
3965
4655
|
border: "none",
|
|
3966
4656
|
borderRadius: "8px",
|
|
3967
4657
|
fontSize: "14px",
|
|
3968
4658
|
fontWeight: 600,
|
|
3969
|
-
cursor: "pointer"
|
|
4659
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
4660
|
+
opacity: isLoading ? 0.6 : 1,
|
|
4661
|
+
transition: "all 0.2s ease"
|
|
3970
4662
|
},
|
|
3971
|
-
children: "Request Email Change"
|
|
4663
|
+
children: isLoading ? "Sending..." : "Request Email Change"
|
|
3972
4664
|
}
|
|
3973
4665
|
)
|
|
3974
4666
|
] })
|
|
@@ -3977,7 +4669,7 @@ var UserProfile = ({
|
|
|
3977
4669
|
};
|
|
3978
4670
|
var isServer = typeof window === "undefined";
|
|
3979
4671
|
var useNextAuth = (config) => {
|
|
3980
|
-
const [authService] =
|
|
4672
|
+
const [authService] = React3.useState(() => {
|
|
3981
4673
|
const service = new AuthService(config);
|
|
3982
4674
|
if (isServer && config.token) {
|
|
3983
4675
|
service["token"] = config.token;
|
|
@@ -3985,10 +4677,10 @@ var useNextAuth = (config) => {
|
|
|
3985
4677
|
}
|
|
3986
4678
|
return service;
|
|
3987
4679
|
});
|
|
3988
|
-
const [user, setUser] =
|
|
3989
|
-
const [isAuthenticated, setIsAuthenticated] =
|
|
3990
|
-
const [loading, setLoading] =
|
|
3991
|
-
const checkAuthStatus =
|
|
4680
|
+
const [user, setUser] = React3.useState(null);
|
|
4681
|
+
const [isAuthenticated, setIsAuthenticated] = React3.useState(false);
|
|
4682
|
+
const [loading, setLoading] = React3.useState(true);
|
|
4683
|
+
const checkAuthStatus = React3.useCallback(() => {
|
|
3992
4684
|
if (isServer) {
|
|
3993
4685
|
const token = config.token || authService.getToken();
|
|
3994
4686
|
const authenticated = !!token;
|
|
@@ -4016,10 +4708,10 @@ var useNextAuth = (config) => {
|
|
|
4016
4708
|
}
|
|
4017
4709
|
setLoading(false);
|
|
4018
4710
|
}, [authService, config.token]);
|
|
4019
|
-
|
|
4711
|
+
React3.useEffect(() => {
|
|
4020
4712
|
checkAuthStatus();
|
|
4021
4713
|
}, [checkAuthStatus]);
|
|
4022
|
-
const register =
|
|
4714
|
+
const register = React3.useCallback(async (data) => {
|
|
4023
4715
|
setLoading(true);
|
|
4024
4716
|
try {
|
|
4025
4717
|
const response = await authService.register(data);
|
|
@@ -4028,7 +4720,7 @@ var useNextAuth = (config) => {
|
|
|
4028
4720
|
setLoading(false);
|
|
4029
4721
|
}
|
|
4030
4722
|
}, [authService]);
|
|
4031
|
-
const login =
|
|
4723
|
+
const login = React3.useCallback(async (data) => {
|
|
4032
4724
|
setLoading(true);
|
|
4033
4725
|
try {
|
|
4034
4726
|
const response = await authService.login(data);
|
|
@@ -4037,7 +4729,7 @@ var useNextAuth = (config) => {
|
|
|
4037
4729
|
setLoading(false);
|
|
4038
4730
|
}
|
|
4039
4731
|
}, [authService]);
|
|
4040
|
-
const verify =
|
|
4732
|
+
const verify = React3.useCallback(async (data) => {
|
|
4041
4733
|
setLoading(true);
|
|
4042
4734
|
try {
|
|
4043
4735
|
const response = await authService.verify(data);
|
|
@@ -4050,7 +4742,7 @@ var useNextAuth = (config) => {
|
|
|
4050
4742
|
setLoading(false);
|
|
4051
4743
|
}
|
|
4052
4744
|
}, [authService]);
|
|
4053
|
-
const verifyEmailToken =
|
|
4745
|
+
const verifyEmailToken = React3.useCallback(async (token) => {
|
|
4054
4746
|
setLoading(true);
|
|
4055
4747
|
try {
|
|
4056
4748
|
const response = await authService.verifyEmailToken(token);
|
|
@@ -4063,7 +4755,7 @@ var useNextAuth = (config) => {
|
|
|
4063
4755
|
setLoading(false);
|
|
4064
4756
|
}
|
|
4065
4757
|
}, [authService]);
|
|
4066
|
-
const logout =
|
|
4758
|
+
const logout = React3.useCallback(async () => {
|
|
4067
4759
|
setLoading(true);
|
|
4068
4760
|
try {
|
|
4069
4761
|
await authService.logout();
|
|
@@ -4073,7 +4765,7 @@ var useNextAuth = (config) => {
|
|
|
4073
4765
|
setLoading(false);
|
|
4074
4766
|
}
|
|
4075
4767
|
}, [authService]);
|
|
4076
|
-
const updateProfile =
|
|
4768
|
+
const updateProfile = React3.useCallback(async (data) => {
|
|
4077
4769
|
setLoading(true);
|
|
4078
4770
|
try {
|
|
4079
4771
|
const response = await authService.updateProfile(data);
|
|
@@ -4085,7 +4777,7 @@ var useNextAuth = (config) => {
|
|
|
4085
4777
|
setLoading(false);
|
|
4086
4778
|
}
|
|
4087
4779
|
}, [authService]);
|
|
4088
|
-
const getProfile =
|
|
4780
|
+
const getProfile = React3.useCallback(async () => {
|
|
4089
4781
|
setLoading(true);
|
|
4090
4782
|
try {
|
|
4091
4783
|
const userData = await authService.getProfile();
|
|
@@ -4095,7 +4787,7 @@ var useNextAuth = (config) => {
|
|
|
4095
4787
|
setLoading(false);
|
|
4096
4788
|
}
|
|
4097
4789
|
}, [authService]);
|
|
4098
|
-
const getAllUsers =
|
|
4790
|
+
const getAllUsers = React3.useCallback(async () => {
|
|
4099
4791
|
setLoading(true);
|
|
4100
4792
|
try {
|
|
4101
4793
|
return await authService.getAllUsers();
|
|
@@ -4103,7 +4795,7 @@ var useNextAuth = (config) => {
|
|
|
4103
4795
|
setLoading(false);
|
|
4104
4796
|
}
|
|
4105
4797
|
}, [authService]);
|
|
4106
|
-
const getUserById =
|
|
4798
|
+
const getUserById = React3.useCallback(async (id) => {
|
|
4107
4799
|
setLoading(true);
|
|
4108
4800
|
try {
|
|
4109
4801
|
return await authService.getUserById(id);
|
|
@@ -4111,7 +4803,7 @@ var useNextAuth = (config) => {
|
|
|
4111
4803
|
setLoading(false);
|
|
4112
4804
|
}
|
|
4113
4805
|
}, [authService]);
|
|
4114
|
-
const forgotPassword =
|
|
4806
|
+
const forgotPassword = React3.useCallback(async (email) => {
|
|
4115
4807
|
setLoading(true);
|
|
4116
4808
|
try {
|
|
4117
4809
|
const response = await authService.forgotPassword(email);
|
|
@@ -4120,7 +4812,7 @@ var useNextAuth = (config) => {
|
|
|
4120
4812
|
setLoading(false);
|
|
4121
4813
|
}
|
|
4122
4814
|
}, [authService]);
|
|
4123
|
-
const resetPassword =
|
|
4815
|
+
const resetPassword = React3.useCallback(async (token, password) => {
|
|
4124
4816
|
setLoading(true);
|
|
4125
4817
|
try {
|
|
4126
4818
|
const response = await authService.resetPassword(token, password);
|
|
@@ -4129,7 +4821,7 @@ var useNextAuth = (config) => {
|
|
|
4129
4821
|
setLoading(false);
|
|
4130
4822
|
}
|
|
4131
4823
|
}, [authService]);
|
|
4132
|
-
const setToken =
|
|
4824
|
+
const setToken = React3.useCallback((token) => {
|
|
4133
4825
|
authService["token"] = token;
|
|
4134
4826
|
authService["httpClient"].setAuthToken(token);
|
|
4135
4827
|
setIsAuthenticated(true);
|
|
@@ -4141,7 +4833,7 @@ var useNextAuth = (config) => {
|
|
|
4141
4833
|
setUser(null);
|
|
4142
4834
|
}
|
|
4143
4835
|
}, [authService]);
|
|
4144
|
-
const clearToken =
|
|
4836
|
+
const clearToken = React3.useCallback(() => {
|
|
4145
4837
|
authService["token"] = null;
|
|
4146
4838
|
authService["httpClient"].removeAuthToken();
|
|
4147
4839
|
setIsAuthenticated(false);
|
|
@@ -4170,12 +4862,14 @@ var useNextAuth = (config) => {
|
|
|
4170
4862
|
exports.AuthFlow = AuthFlow;
|
|
4171
4863
|
exports.AuthProvider = AuthProvider;
|
|
4172
4864
|
exports.AuthService = AuthService;
|
|
4865
|
+
exports.AuthThemeProvider = AuthThemeProvider;
|
|
4173
4866
|
exports.ChangePassword = ChangePassword;
|
|
4174
4867
|
exports.EmailVerificationPage = EmailVerificationPage;
|
|
4175
4868
|
exports.ForgotPassword = ForgotPassword;
|
|
4176
4869
|
exports.HttpClient = HttpClient;
|
|
4177
4870
|
exports.LoginForm = LoginForm;
|
|
4178
4871
|
exports.OtpForm = OtpForm;
|
|
4872
|
+
exports.PhoneInput = PhoneInput;
|
|
4179
4873
|
exports.ProtectedRoute = ProtectedRoute;
|
|
4180
4874
|
exports.PublicRoute = PublicRoute;
|
|
4181
4875
|
exports.RegisterForm = RegisterForm;
|
|
@@ -4188,6 +4882,7 @@ exports.UserProfile = UserProfile;
|
|
|
4188
4882
|
exports.VerifyEmail = VerifyEmail;
|
|
4189
4883
|
exports.useAuth = useAuth2;
|
|
4190
4884
|
exports.useAuthLegacy = useAuth;
|
|
4885
|
+
exports.useAuthTheme = useAuthTheme;
|
|
4191
4886
|
exports.useNextAuth = useNextAuth;
|
|
4192
4887
|
//# sourceMappingURL=out.js.map
|
|
4193
4888
|
//# sourceMappingURL=index.next.js.map
|