Spaces:
Running
Running
Pulastya B commited on
Commit ·
27c2ee9
1
Parent(s): 8dcc270
Fix OAuth redirect loop and disable email editing for OAuth users
Browse files
FRRONTEEEND/components/AuthPage.tsx
CHANGED
|
@@ -225,23 +225,29 @@ export const AuthPage: React.FC<AuthPageProps> = ({ onSuccess, onSkip }) => {
|
|
| 225 |
try {
|
| 226 |
const savedProfile = await saveProfileWithTimeout;
|
| 227 |
if (!savedProfile) {
|
| 228 |
-
console.
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
} catch (saveError: any) {
|
| 234 |
console.error('Profile save error:', saveError);
|
| 235 |
if (saveError.message === 'Profile save timeout') {
|
| 236 |
-
setError('Profile save is taking too long.
|
|
|
|
|
|
|
| 237 |
}
|
| 238 |
-
|
|
|
|
| 239 |
}
|
| 240 |
-
|
| 241 |
-
setSuccess(isOAuthUser ? 'Profile completed! Redirecting...' : 'Account created successfully! Redirecting...');
|
| 242 |
-
setTimeout(() => {
|
| 243 |
-
onSuccess?.();
|
| 244 |
-
}, 1500);
|
| 245 |
} catch (err: any) {
|
| 246 |
if (err.message?.includes('Failed to fetch')) {
|
| 247 |
setError('Unable to connect to authentication server. Please try again later.');
|
|
@@ -571,8 +577,15 @@ export const AuthPage: React.FC<AuthPageProps> = ({ onSuccess, onSkip }) => {
|
|
| 571 |
placeholder="john@example.com"
|
| 572 |
value={formData.email}
|
| 573 |
onChange={(e) => updateFormData("email", e.target.value)}
|
| 574 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
/>
|
|
|
|
|
|
|
|
|
|
| 576 |
</div>
|
| 577 |
</motion.div>
|
| 578 |
|
|
|
|
| 225 |
try {
|
| 226 |
const savedProfile = await saveProfileWithTimeout;
|
| 227 |
if (!savedProfile) {
|
| 228 |
+
console.error('Failed to save profile data');
|
| 229 |
+
setError('Failed to save your profile. Please try again.');
|
| 230 |
+
setIsSubmitting(false);
|
| 231 |
+
return;
|
| 232 |
}
|
| 233 |
+
|
| 234 |
+
console.log('Profile saved successfully:', savedProfile);
|
| 235 |
+
|
| 236 |
+
// Only proceed if profile was saved successfully
|
| 237 |
+
setSuccess(isOAuthUser ? 'Profile completed! Redirecting...' : 'Account created successfully! Redirecting...');
|
| 238 |
+
setTimeout(() => {
|
| 239 |
+
onSuccess?.();
|
| 240 |
+
}, 1500);
|
| 241 |
} catch (saveError: any) {
|
| 242 |
console.error('Profile save error:', saveError);
|
| 243 |
if (saveError.message === 'Profile save timeout') {
|
| 244 |
+
setError('Profile save is taking too long. Please try again.');
|
| 245 |
+
} else {
|
| 246 |
+
setError('Failed to save your profile. Please try again.');
|
| 247 |
}
|
| 248 |
+
setIsSubmitting(false);
|
| 249 |
+
return;
|
| 250 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
} catch (err: any) {
|
| 252 |
if (err.message?.includes('Failed to fetch')) {
|
| 253 |
setError('Unable to connect to authentication server. Please try again later.');
|
|
|
|
| 577 |
placeholder="john@example.com"
|
| 578 |
value={formData.email}
|
| 579 |
onChange={(e) => updateFormData("email", e.target.value)}
|
| 580 |
+
disabled={!!user}
|
| 581 |
+
className={cn(
|
| 582 |
+
"pl-10 bg-white/5 border-white/10 text-white placeholder:text-white/30 focus:border-indigo-500/50",
|
| 583 |
+
user && "opacity-60 cursor-not-allowed"
|
| 584 |
+
)}
|
| 585 |
/>
|
| 586 |
+
{user && (
|
| 587 |
+
<p className="text-xs text-white/40 mt-1">Email from OAuth provider</p>
|
| 588 |
+
)}
|
| 589 |
</div>
|
| 590 |
</motion.div>
|
| 591 |
|