mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 17:31:12 -05:00
Fix: Improve password verification and sync
This commit is contained in:
@@ -164,22 +164,26 @@ export async function connectIdentity(
|
||||
* Wait for email provider to be created after password addition
|
||||
* Supabase takes time to create the email identity, so we poll with retries
|
||||
*/
|
||||
async function waitForEmailProvider(maxRetries = 4): Promise<boolean> {
|
||||
const delays = [500, 1000, 1500, 2000]; // Exponential backoff
|
||||
async function waitForEmailProvider(maxRetries = 6): Promise<boolean> {
|
||||
const delays = [500, 1000, 1500, 2000, 2500, 3000]; // ~10.5s total
|
||||
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
const identities = await getUserIdentities();
|
||||
const hasEmail = identities.some(id => id.provider === 'email');
|
||||
|
||||
if (hasEmail) {
|
||||
console.log(`[IdentityService] Email provider found after ${i + 1} attempts`);
|
||||
return true;
|
||||
}
|
||||
|
||||
console.log(`[IdentityService] Email provider not found, attempt ${i + 1}/${maxRetries}`);
|
||||
|
||||
if (i < maxRetries - 1) {
|
||||
await new Promise(resolve => setTimeout(resolve, delays[i]));
|
||||
}
|
||||
}
|
||||
|
||||
console.error('[IdentityService] Email provider not found after max retries');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -213,7 +217,10 @@ export async function addPasswordToAccount(
|
||||
const emailCreated = await waitForEmailProvider();
|
||||
|
||||
if (!emailCreated) {
|
||||
console.warn('[IdentityService] Email provider not found after password addition');
|
||||
return {
|
||||
success: false,
|
||||
error: 'Password was set but email provider verification failed. Please refresh the page and try signing in with your email and password.'
|
||||
};
|
||||
}
|
||||
|
||||
// Log audit event
|
||||
|
||||
Reference in New Issue
Block a user