bulltrackers-module 1.0.595 → 1.0.596

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.
@@ -1517,7 +1517,7 @@ const finalizeVerification = async (db, pubsub, userId, username) => {
1517
1517
  isOptOut
1518
1518
  });
1519
1519
 
1520
- // 2. Create/Update User Doc in SignedInUsers
1520
+ // 2. Create/Update User Doc in SignedInUsers (legacy location - for backward compatibility)
1521
1521
  // Note: We use the realCID as the document ID, matching the generic-api logic
1522
1522
  await db.collection(signedInUsersCollection).doc(String(realCID)).set({
1523
1523
  username: profileData.username,
@@ -1529,7 +1529,30 @@ const finalizeVerification = async (db, pubsub, userId, username) => {
1529
1529
  lastLogin: FieldValue.serverTimestamp()
1530
1530
  }, { merge: true });
1531
1531
 
1532
- // 3. Trigger Downstream Systems via Task Engine
1532
+ // 3. Create/Update verification data in new format location: /SignedInUsers/{cid}/verification/data
1533
+ const verificationDataRef = db.collection('SignedInUsers').doc(String(realCID)).collection('verification').doc('data');
1534
+ const existingVerificationDoc = await verificationDataRef.get();
1535
+
1536
+ let emails = [];
1537
+ if (existingVerificationDoc.exists()) {
1538
+ const existingData = existingVerificationDoc.data();
1539
+ // Preserve existing email array if present
1540
+ emails = Array.isArray(existingData.email) ? existingData.email : (existingData.email ? [existingData.email] : []);
1541
+ }
1542
+ // Note: Email will be added by frontend completeAccountSetup when Firebase Auth email is available
1543
+
1544
+ await verificationDataRef.set({
1545
+ etoroUsername: profileData.username,
1546
+ etoroCID: realCID,
1547
+ email: emails, // Array - will be populated by frontend
1548
+ displayName: `${profileData.firstName || ''} ${profileData.lastName || ''}`.trim(),
1549
+ photoURL: profileData.avatars?.find(a => a.type === 'Original')?.url || null,
1550
+ verifiedAt: FieldValue.serverTimestamp(),
1551
+ accountSetupComplete: false, // Will be set to true by frontend completeAccountSetup
1552
+ createdAt: FieldValue.serverTimestamp(),
1553
+ }, { merge: true });
1554
+
1555
+ // 4. Trigger Downstream Systems via Task Engine
1533
1556
  if (pubsub) {
1534
1557
  try {
1535
1558
  // Replicating the 'unifiedTask' payload from generic-api
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.595",
3
+ "version": "1.0.596",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [