@onairos/react-native 3.0.66 โ 3.0.68
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/lib/commonjs/components/EmailVerificationModal.js +7 -6
- package/lib/commonjs/components/EmailVerificationModal.js.map +1 -1
- package/lib/commonjs/components/TrainingModal.js +17 -9
- package/lib/commonjs/components/TrainingModal.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +243 -44
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
- package/lib/commonjs/index.js +13 -54
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/services/platformAuthService.js +91 -40
- package/lib/commonjs/services/platformAuthService.js.map +1 -1
- package/lib/module/components/EmailVerificationModal.js +7 -6
- package/lib/module/components/EmailVerificationModal.js.map +1 -1
- package/lib/module/components/TrainingModal.js +17 -9
- package/lib/module/components/TrainingModal.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +243 -44
- package/lib/module/components/UniversalOnboarding.js.map +1 -1
- package/lib/module/services/platformAuthService.js +91 -40
- package/lib/module/services/platformAuthService.js.map +1 -1
- package/lib/typescript/components/EmailVerificationModal.d.ts +1 -0
- package/lib/typescript/components/EmailVerificationModal.d.ts.map +1 -1
- package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
- package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
- package/lib/typescript/services/platformAuthService.d.ts +4 -3
- package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/EmailVerificationModal.tsx +10 -6
- package/src/components/TrainingModal.tsx +77 -67
- package/src/components/UniversalOnboarding.tsx +242 -45
- package/src/services/platformAuthService.ts +97 -38
|
@@ -503,9 +503,9 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
503
503
|
|
|
504
504
|
console.log('๐ง Email validation passed, proceeding...');
|
|
505
505
|
|
|
506
|
-
// For
|
|
507
|
-
if (
|
|
508
|
-
console.log('๐งช
|
|
506
|
+
// For test mode, just proceed to verification step without API call
|
|
507
|
+
if (isTestMode) {
|
|
508
|
+
console.log('๐งช Test mode: Skipping API call, proceeding to verification');
|
|
509
509
|
setStep('verify');
|
|
510
510
|
return;
|
|
511
511
|
}
|
|
@@ -538,7 +538,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
538
538
|
|
|
539
539
|
// Race between API call and timeout
|
|
540
540
|
const result = await Promise.race([
|
|
541
|
-
requestEmailVerification(email.trim()),
|
|
541
|
+
requestEmailVerification(email.trim(), isTestMode),
|
|
542
542
|
timeoutPromise
|
|
543
543
|
]) as any;
|
|
544
544
|
|
|
@@ -610,14 +610,14 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
|
|
613
|
-
// Real API call (production)
|
|
614
|
-
const result = await verifyEmailCode(email.trim(), verificationCode.trim());
|
|
613
|
+
// Real API call (production) or test mode
|
|
614
|
+
const result = await verifyEmailCode(email.trim(), verificationCode.trim(), isTestMode);
|
|
615
615
|
|
|
616
616
|
if (result.success) {
|
|
617
617
|
console.log('โ
Email verification successful');
|
|
618
618
|
|
|
619
|
-
|
|
620
|
-
|
|
619
|
+
// Check if user exists in backend (properly typed now)
|
|
620
|
+
const existingUser = result.existingUser || false;
|
|
621
621
|
setIsExistingUser(existingUser);
|
|
622
622
|
|
|
623
623
|
if (existingUser) {
|
|
@@ -685,45 +685,240 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
685
685
|
}
|
|
686
686
|
}, [connections, selectedTier, platformToggles, username, AppName, auto, inferenceData, partner]);
|
|
687
687
|
|
|
688
|
-
const handleTrainingComplete = useCallback(() => {
|
|
688
|
+
const handleTrainingComplete = useCallback(async () => {
|
|
689
689
|
console.log('๐ Training completed successfully');
|
|
690
|
+
console.log('๐ Auto mode enabled:', auto);
|
|
691
|
+
console.log('๐ Inference data available:', !!inferenceData);
|
|
690
692
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
693
|
+
try {
|
|
694
|
+
if (auto && inferenceData) {
|
|
695
|
+
console.log('๐ค Auto mode: Making API request to get URL and perform inference');
|
|
696
|
+
|
|
697
|
+
// First, get the API URL from backend
|
|
698
|
+
const apiUrlResponse = await fetch('https://api2.onairos.uk/', {
|
|
699
|
+
method: 'POST',
|
|
700
|
+
headers: {
|
|
701
|
+
'Content-Type': 'application/json',
|
|
702
|
+
},
|
|
703
|
+
body: JSON.stringify({
|
|
704
|
+
Info: {
|
|
705
|
+
storage: 'secure',
|
|
706
|
+
appId: AppName,
|
|
707
|
+
confirmations: Object.keys(requestData || {}),
|
|
708
|
+
EncryptedUserPin: pin, // Use the actual PIN from user
|
|
709
|
+
account: email.trim(),
|
|
710
|
+
proofMode: false,
|
|
711
|
+
}
|
|
712
|
+
})
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
if (!apiUrlResponse.ok) {
|
|
716
|
+
throw new Error(`Failed to get API URL: ${apiUrlResponse.status}`);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
const { apiUrl, token } = await apiUrlResponse.json();
|
|
720
|
+
console.log('โ
Received API URL:', apiUrl);
|
|
721
|
+
console.log('โ
Received token:', token?.substring(0, 20) + '...');
|
|
722
|
+
|
|
723
|
+
// Now make the inference call with the provided data
|
|
724
|
+
const inferenceResponse = await fetch(apiUrl, {
|
|
725
|
+
method: 'POST',
|
|
726
|
+
headers: {
|
|
727
|
+
'Content-Type': 'application/json',
|
|
728
|
+
'Authorization': `Bearer ${token}`,
|
|
729
|
+
},
|
|
730
|
+
body: JSON.stringify({
|
|
731
|
+
...inferenceData,
|
|
732
|
+
userEmail: email.trim(),
|
|
733
|
+
appName: AppName,
|
|
734
|
+
timestamp: new Date().toISOString(),
|
|
735
|
+
})
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
if (!inferenceResponse.ok) {
|
|
739
|
+
throw new Error(`Inference API failed: ${inferenceResponse.status}`);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
const inferenceResults = await inferenceResponse.json();
|
|
743
|
+
console.log('โ
Auto mode inference results:', inferenceResults);
|
|
744
|
+
|
|
745
|
+
// Close the modal first
|
|
746
|
+
handleClose();
|
|
747
|
+
|
|
748
|
+
// Complete onboarding with inference results
|
|
749
|
+
setTimeout(() => {
|
|
750
|
+
onComplete(apiUrl, token, {
|
|
751
|
+
pin,
|
|
752
|
+
connections,
|
|
753
|
+
platformToggles,
|
|
754
|
+
selectedTier,
|
|
755
|
+
tierData: requestData?.[selectedTier],
|
|
756
|
+
sessionSaved: true,
|
|
757
|
+
// Add inference data if auto mode is enabled
|
|
758
|
+
...(auto && inferenceData && { inferenceData }),
|
|
759
|
+
// Add partner info for special partners
|
|
760
|
+
...(partner && { partner: partner === 'couplebible' ? 'CoupleBible' : partner }),
|
|
761
|
+
autoMode: true,
|
|
762
|
+
inferenceResults,
|
|
763
|
+
apiUrl,
|
|
764
|
+
token,
|
|
765
|
+
});
|
|
766
|
+
}, 100);
|
|
767
|
+
|
|
768
|
+
} else {
|
|
769
|
+
console.log('๐ Standard mode: Returning API URL for manual use');
|
|
770
|
+
|
|
771
|
+
// Prepare completion data
|
|
772
|
+
const completionData = {
|
|
773
|
+
pin,
|
|
774
|
+
connections,
|
|
775
|
+
platformToggles,
|
|
776
|
+
selectedTier,
|
|
777
|
+
tierData: requestData?.[selectedTier],
|
|
778
|
+
sessionSaved: true,
|
|
779
|
+
// Add inference data if auto mode is enabled
|
|
780
|
+
...(auto && inferenceData && { inferenceData }),
|
|
781
|
+
// Add partner info for special partners
|
|
782
|
+
...(partner && { partner: partner === 'couplebible' ? 'CoupleBible' : partner }),
|
|
783
|
+
autoMode: false,
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
console.log('Completion data prepared:', completionData);
|
|
787
|
+
|
|
788
|
+
// Close the modal first
|
|
789
|
+
handleClose();
|
|
790
|
+
|
|
791
|
+
// Then call the completion callback
|
|
792
|
+
setTimeout(() => {
|
|
793
|
+
onComplete('https://api2.onairos.uk', 'dummy-token', completionData);
|
|
794
|
+
}, 100);
|
|
795
|
+
}
|
|
796
|
+
} catch (error) {
|
|
797
|
+
console.error('โ Error in training complete:', error);
|
|
798
|
+
|
|
799
|
+
// Fallback to standard mode
|
|
800
|
+
const completionData = {
|
|
801
|
+
pin,
|
|
802
|
+
connections,
|
|
803
|
+
platformToggles,
|
|
804
|
+
selectedTier,
|
|
805
|
+
tierData: requestData?.[selectedTier],
|
|
806
|
+
sessionSaved: true,
|
|
807
|
+
// Add inference data if auto mode is enabled
|
|
808
|
+
...(auto && inferenceData && { inferenceData }),
|
|
809
|
+
// Add partner info for special partners
|
|
810
|
+
...(partner && { partner: partner === 'couplebible' ? 'CoupleBible' : partner }),
|
|
811
|
+
autoMode: false,
|
|
812
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
console.log('Fallback completion data:', completionData);
|
|
816
|
+
|
|
817
|
+
// Close the modal first
|
|
818
|
+
handleClose();
|
|
819
|
+
|
|
820
|
+
// Then call the completion callback
|
|
821
|
+
setTimeout(() => {
|
|
822
|
+
onComplete('https://api2.onairos.uk', 'dummy-token', completionData);
|
|
823
|
+
}, 100);
|
|
824
|
+
}
|
|
825
|
+
}, [pin, connections, platformToggles, selectedTier, requestData, auto, inferenceData, partner, handleClose, onComplete, AppName, email]);
|
|
715
826
|
|
|
716
|
-
const handleDataRequestAccept = useCallback(() => {
|
|
827
|
+
const handleDataRequestAccept = useCallback(async () => {
|
|
717
828
|
console.log('Data request accepted for existing user');
|
|
829
|
+
console.log('๐ Auto mode enabled:', auto);
|
|
830
|
+
console.log('๐ Inference data available:', !!inferenceData);
|
|
718
831
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
832
|
+
try {
|
|
833
|
+
if (auto && inferenceData) {
|
|
834
|
+
console.log('๐ค Auto mode: Making API request to get URL and perform inference');
|
|
835
|
+
|
|
836
|
+
// First, get the API URL from backend
|
|
837
|
+
const apiUrlResponse = await fetch('https://api2.onairos.uk/', {
|
|
838
|
+
method: 'POST',
|
|
839
|
+
headers: {
|
|
840
|
+
'Content-Type': 'application/json',
|
|
841
|
+
},
|
|
842
|
+
body: JSON.stringify({
|
|
843
|
+
Info: {
|
|
844
|
+
storage: 'secure', // or whatever storage type
|
|
845
|
+
appId: AppName,
|
|
846
|
+
confirmations: Object.keys(requestData || {}),
|
|
847
|
+
EncryptedUserPin: 'temp-pin', // This would come from user PIN in real flow
|
|
848
|
+
account: email.trim(),
|
|
849
|
+
proofMode: false,
|
|
850
|
+
}
|
|
851
|
+
})
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
if (!apiUrlResponse.ok) {
|
|
855
|
+
throw new Error(`Failed to get API URL: ${apiUrlResponse.status}`);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
const { apiUrl, token } = await apiUrlResponse.json();
|
|
859
|
+
console.log('โ
Received API URL:', apiUrl);
|
|
860
|
+
console.log('โ
Received token:', token?.substring(0, 20) + '...');
|
|
861
|
+
|
|
862
|
+
// Now make the inference call with the provided data
|
|
863
|
+
const inferenceResponse = await fetch(apiUrl, {
|
|
864
|
+
method: 'POST',
|
|
865
|
+
headers: {
|
|
866
|
+
'Content-Type': 'application/json',
|
|
867
|
+
'Authorization': `Bearer ${token}`,
|
|
868
|
+
},
|
|
869
|
+
body: JSON.stringify({
|
|
870
|
+
...inferenceData,
|
|
871
|
+
userEmail: email.trim(),
|
|
872
|
+
appName: AppName,
|
|
873
|
+
timestamp: new Date().toISOString(),
|
|
874
|
+
})
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
if (!inferenceResponse.ok) {
|
|
878
|
+
throw new Error(`Inference API failed: ${inferenceResponse.status}`);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
const inferenceResults = await inferenceResponse.json();
|
|
882
|
+
console.log('โ
Auto mode inference results:', inferenceResults);
|
|
883
|
+
|
|
884
|
+
// Complete onboarding with inference results
|
|
885
|
+
onComplete(apiUrl, token, {
|
|
886
|
+
existingAccount: true,
|
|
887
|
+
email: email.trim(),
|
|
888
|
+
dataRequestAccepted: true,
|
|
889
|
+
requestData,
|
|
890
|
+
autoMode: true,
|
|
891
|
+
inferenceResults,
|
|
892
|
+
apiUrl,
|
|
893
|
+
token,
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
} else {
|
|
897
|
+
console.log('๐ Standard mode: Returning API URL for manual use');
|
|
898
|
+
|
|
899
|
+
// Standard mode: just return the API URL
|
|
900
|
+
onComplete('https://api2.onairos.uk', 'existing-session-token', {
|
|
901
|
+
existingAccount: true,
|
|
902
|
+
email: email.trim(),
|
|
903
|
+
dataRequestAccepted: true,
|
|
904
|
+
requestData,
|
|
905
|
+
autoMode: false,
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
} catch (error) {
|
|
909
|
+
console.error('โ Error in data request accept:', error);
|
|
910
|
+
|
|
911
|
+
// Fallback to standard mode
|
|
912
|
+
onComplete('https://api2.onairos.uk', 'existing-session-token', {
|
|
913
|
+
existingAccount: true,
|
|
914
|
+
email: email.trim(),
|
|
915
|
+
dataRequestAccepted: true,
|
|
916
|
+
requestData,
|
|
917
|
+
autoMode: false,
|
|
918
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
}, [email, onComplete, requestData, auto, inferenceData, AppName]);
|
|
727
922
|
|
|
728
923
|
const handleDataRequestDecline = useCallback(() => {
|
|
729
924
|
console.log('Data request declined');
|
|
@@ -844,9 +1039,11 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
|
|
|
844
1039
|
<Text style={styles.emailSubtitle}>
|
|
845
1040
|
We've sent a 6-digit code to {email}
|
|
846
1041
|
</Text>
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
1042
|
+
{isTestMode && (
|
|
1043
|
+
<Text style={styles.developmentNote}>
|
|
1044
|
+
๐ Test Mode: Any 6-digit code will work
|
|
1045
|
+
</Text>
|
|
1046
|
+
)}
|
|
850
1047
|
</View>
|
|
851
1048
|
|
|
852
1049
|
<View style={styles.emailInputSection}>
|
|
@@ -174,6 +174,12 @@ export const initiateOAuth = async (platform: string, username: string, appName?
|
|
|
174
174
|
const data = await response.json();
|
|
175
175
|
console.log(`๐ฅ ${platform} OAuth response data:`, data);
|
|
176
176
|
|
|
177
|
+
// Extra logging for Gmail to help debug
|
|
178
|
+
if (platform === 'email') {
|
|
179
|
+
console.log('๐ Gmail OAuth response keys:', Object.keys(data));
|
|
180
|
+
console.log('๐ Gmail OAuth full response:', JSON.stringify(data, null, 2));
|
|
181
|
+
}
|
|
182
|
+
|
|
177
183
|
// Check if the response contains the OAuth URL based on platform
|
|
178
184
|
switch (platform) {
|
|
179
185
|
case 'reddit':
|
|
@@ -186,13 +192,18 @@ export const initiateOAuth = async (platform: string, username: string, appName?
|
|
|
186
192
|
if (data.youtubeURL) return data.youtubeURL;
|
|
187
193
|
break;
|
|
188
194
|
case 'email':
|
|
195
|
+
// Gmail might return under different field names
|
|
189
196
|
if (data.emailURL) return data.emailURL;
|
|
197
|
+
if (data.gmailURL) return data.gmailURL;
|
|
198
|
+
if (data.authUrl) return data.authUrl;
|
|
199
|
+
if (data.url) return data.url;
|
|
190
200
|
break;
|
|
191
201
|
default:
|
|
192
202
|
if (data.url) return data.url;
|
|
193
203
|
break;
|
|
194
204
|
}
|
|
195
205
|
|
|
206
|
+
console.error(`โ No OAuth URL found in response for ${platform}. Response:`, data);
|
|
196
207
|
throw new Error(`No OAuth URL found in response for ${platform}`);
|
|
197
208
|
} catch (error) {
|
|
198
209
|
console.error(`Error initiating OAuth for ${platform}:`, error);
|
|
@@ -654,15 +665,17 @@ export const updateGoogleClientIds = (config: {
|
|
|
654
665
|
* ๐ง EMAIL VERIFICATION FUNCTIONS
|
|
655
666
|
* Using the correct Onairos email verification endpoints
|
|
656
667
|
*/
|
|
657
|
-
export const requestEmailVerification = async (email: string): Promise<{
|
|
668
|
+
export const requestEmailVerification = async (email: string, testMode = false): Promise<{
|
|
658
669
|
success: boolean;
|
|
659
670
|
message?: string;
|
|
660
671
|
error?: string;
|
|
661
672
|
}> => {
|
|
662
673
|
try {
|
|
663
674
|
console.log('๐ง Requesting email verification for:', email);
|
|
675
|
+
console.log('๐ Test mode:', testMode);
|
|
664
676
|
|
|
665
|
-
|
|
677
|
+
// Use the correct endpoint: /email/verify
|
|
678
|
+
const response = await fetch('https://api2.onairos.uk/email/verify', {
|
|
666
679
|
method: 'POST',
|
|
667
680
|
headers: {
|
|
668
681
|
'Content-Type': 'application/json',
|
|
@@ -674,10 +687,14 @@ export const requestEmailVerification = async (email: string): Promise<{
|
|
|
674
687
|
|
|
675
688
|
if (response.ok && result.success) {
|
|
676
689
|
console.log('โ
Email verification requested successfully');
|
|
677
|
-
|
|
690
|
+
|
|
691
|
+
const message = testMode
|
|
692
|
+
? 'Verification code sent to your email (testing mode: any code accepted)'
|
|
693
|
+
: result.message || 'Verification code sent to your email';
|
|
694
|
+
|
|
678
695
|
return {
|
|
679
696
|
success: true,
|
|
680
|
-
message
|
|
697
|
+
message,
|
|
681
698
|
};
|
|
682
699
|
} else {
|
|
683
700
|
console.error('โ Email verification request failed:', result.error);
|
|
@@ -695,49 +712,72 @@ export const requestEmailVerification = async (email: string): Promise<{
|
|
|
695
712
|
}
|
|
696
713
|
};
|
|
697
714
|
|
|
698
|
-
export const verifyEmailCode = async (email: string, code: string): Promise<{
|
|
715
|
+
export const verifyEmailCode = async (email: string, code: string, testMode = false): Promise<{
|
|
699
716
|
success: boolean;
|
|
700
717
|
message?: string;
|
|
701
718
|
error?: string;
|
|
719
|
+
existingUser?: boolean;
|
|
702
720
|
}> => {
|
|
703
721
|
try {
|
|
704
722
|
console.log('๐ Verifying email code for:', email);
|
|
705
|
-
console.log('๐
|
|
723
|
+
console.log('๐ Test mode:', testMode);
|
|
724
|
+
|
|
725
|
+
// In test mode, accept any code
|
|
726
|
+
if (testMode) {
|
|
727
|
+
console.log('๐งช Test mode: All codes will pass through');
|
|
728
|
+
// Simulate 30% chance of existing user in test mode
|
|
729
|
+
const simulateExistingUser = Math.random() < 0.3;
|
|
730
|
+
return {
|
|
731
|
+
success: true,
|
|
732
|
+
message: 'Email verified successfully (test mode: all codes accepted)',
|
|
733
|
+
existingUser: simulateExistingUser,
|
|
734
|
+
};
|
|
735
|
+
}
|
|
706
736
|
|
|
707
|
-
//
|
|
708
|
-
// Still make the API call to set up the routing, but don't rely on response
|
|
737
|
+
// Production mode: Make real API call with proper validation
|
|
709
738
|
try {
|
|
710
|
-
const response = await fetch('https://api2.onairos.uk/email/
|
|
739
|
+
const response = await fetch('https://api2.onairos.uk/email/verify/confirm', {
|
|
711
740
|
method: 'POST',
|
|
712
741
|
headers: {
|
|
713
742
|
'Content-Type': 'application/json',
|
|
714
743
|
},
|
|
715
|
-
body: JSON.stringify({ email, code
|
|
744
|
+
body: JSON.stringify({ email, code }),
|
|
716
745
|
});
|
|
717
746
|
|
|
718
747
|
const result = await response.json();
|
|
719
748
|
console.log('๐ก Email verification API response:', result);
|
|
749
|
+
|
|
750
|
+
if (response.ok && result.success) {
|
|
751
|
+
console.log('โ
Email verification successful');
|
|
752
|
+
return {
|
|
753
|
+
success: true,
|
|
754
|
+
message: result.message || 'Email verified successfully',
|
|
755
|
+
existingUser: result.existingUser || false, // Backend should return this flag
|
|
756
|
+
};
|
|
757
|
+
} else {
|
|
758
|
+
console.error('โ Email verification failed:', result.error);
|
|
759
|
+
return {
|
|
760
|
+
success: false,
|
|
761
|
+
error: result.error || 'Invalid verification code',
|
|
762
|
+
};
|
|
763
|
+
}
|
|
720
764
|
} catch (apiError) {
|
|
721
|
-
console.
|
|
765
|
+
console.error('โ Email verification API call failed:', apiError);
|
|
766
|
+
return {
|
|
767
|
+
success: false,
|
|
768
|
+
error: 'Network error during verification',
|
|
769
|
+
};
|
|
722
770
|
}
|
|
723
|
-
|
|
724
|
-
// Always return success for now
|
|
725
|
-
console.log('โ
Email verification successful (bypass mode)');
|
|
726
|
-
return {
|
|
727
|
-
success: true,
|
|
728
|
-
message: 'Email verified successfully (development mode: all codes accepted)',
|
|
729
|
-
};
|
|
730
771
|
} catch (error) {
|
|
731
772
|
console.error('โ Email verification error:', error);
|
|
732
|
-
// Even on error, return success for now
|
|
733
773
|
return {
|
|
734
|
-
success:
|
|
735
|
-
|
|
774
|
+
success: false,
|
|
775
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
736
776
|
};
|
|
737
777
|
}
|
|
738
778
|
};
|
|
739
779
|
|
|
740
|
-
export const checkEmailVerificationStatus = async (email: string): Promise<{
|
|
780
|
+
export const checkEmailVerificationStatus = async (email: string, testMode = false): Promise<{
|
|
741
781
|
success: boolean;
|
|
742
782
|
isPending?: boolean;
|
|
743
783
|
message?: string;
|
|
@@ -745,11 +785,21 @@ export const checkEmailVerificationStatus = async (email: string): Promise<{
|
|
|
745
785
|
}> => {
|
|
746
786
|
try {
|
|
747
787
|
console.log('๐ Checking email verification status for:', email);
|
|
748
|
-
console.log('๐
|
|
788
|
+
console.log('๐ Test mode:', testMode);
|
|
749
789
|
|
|
750
|
-
//
|
|
790
|
+
// In test mode, always return no pending verification
|
|
791
|
+
if (testMode) {
|
|
792
|
+
console.log('๐งช Test mode: Always returning no pending verification');
|
|
793
|
+
return {
|
|
794
|
+
success: true,
|
|
795
|
+
isPending: false,
|
|
796
|
+
message: 'Status retrieved successfully (test mode)',
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// Production mode: Make real API call
|
|
751
801
|
try {
|
|
752
|
-
const response = await fetch(`https://api2.onairos.uk/email/
|
|
802
|
+
const response = await fetch(`https://api2.onairos.uk/email/verify/status/${encodeURIComponent(email)}`, {
|
|
753
803
|
method: 'GET',
|
|
754
804
|
headers: {
|
|
755
805
|
'Content-Type': 'application/json',
|
|
@@ -758,24 +808,33 @@ export const checkEmailVerificationStatus = async (email: string): Promise<{
|
|
|
758
808
|
|
|
759
809
|
const result = await response.json();
|
|
760
810
|
console.log('๐ก Email verification status API response:', result);
|
|
811
|
+
|
|
812
|
+
if (response.ok && result.success) {
|
|
813
|
+
console.log('โ
Email verification status retrieved');
|
|
814
|
+
return {
|
|
815
|
+
success: true,
|
|
816
|
+
isPending: result.isPending || false,
|
|
817
|
+
message: result.message || 'Status retrieved successfully',
|
|
818
|
+
};
|
|
819
|
+
} else {
|
|
820
|
+
console.error('โ Email verification status failed:', result.error);
|
|
821
|
+
return {
|
|
822
|
+
success: false,
|
|
823
|
+
error: result.error || 'Failed to check verification status',
|
|
824
|
+
};
|
|
825
|
+
}
|
|
761
826
|
} catch (apiError) {
|
|
762
|
-
console.
|
|
827
|
+
console.error('โ Email verification status API call failed:', apiError);
|
|
828
|
+
return {
|
|
829
|
+
success: false,
|
|
830
|
+
error: 'Network error while checking status',
|
|
831
|
+
};
|
|
763
832
|
}
|
|
764
|
-
|
|
765
|
-
// For development, always return no pending verification
|
|
766
|
-
console.log('โ
Email verification status retrieved (bypass mode)');
|
|
767
|
-
return {
|
|
768
|
-
success: true,
|
|
769
|
-
isPending: false, // Always false so verification flow starts fresh
|
|
770
|
-
message: 'Status retrieved successfully (development mode)',
|
|
771
|
-
};
|
|
772
833
|
} catch (error) {
|
|
773
834
|
console.error('โ Email verification status error:', error);
|
|
774
|
-
// Even on error, return success for development
|
|
775
835
|
return {
|
|
776
|
-
success:
|
|
777
|
-
|
|
778
|
-
message: 'Status retrieved successfully (development mode)',
|
|
836
|
+
success: false,
|
|
837
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
779
838
|
};
|
|
780
839
|
}
|
|
781
840
|
};
|