about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2023-11-27 18:39:53 -0600
committerGitHub <noreply@github.com>2023-11-27 16:39:53 -0800
commit26bbe0706897d3b00f35e77da9131d0305b633ef (patch)
tree901628c2a4c8295f947eb647d97bbba0a77f782b /src
parent5fd2d36273c2e603084bdd58af43023e9622fb46 (diff)
downloadvoidsky-26bbe0706897d3b00f35e77da9131d0305b633ef.tar.zst
Add more debugging to auth (#2009)
Diffstat (limited to 'src')
-rw-r--r--src/state/persisted/legacy.ts30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/state/persisted/legacy.ts b/src/state/persisted/legacy.ts
index 170401723..025877529 100644
--- a/src/state/persisted/legacy.ts
+++ b/src/state/persisted/legacy.ts
@@ -122,7 +122,35 @@ export async function migrate() {
     const rawLegacyData = await AsyncStorage.getItem(
       DEPRECATED_ROOT_STATE_STORAGE_KEY,
     )
-    const alreadyMigrated = Boolean(await read())
+    const newData = await read()
+    const alreadyMigrated = Boolean(newData)
+
+    try {
+      if (rawLegacyData) {
+        const legacy = JSON.parse(rawLegacyData) as Partial<LegacySchema>
+        logger.info(`persisted state: debug legacy data`, {
+          hasExistingLoggedInAccount: Boolean(legacy?.session?.data),
+          numberOfExistingAccounts: legacy?.session?.accounts?.length,
+          foundExistingCurrentAccount: Boolean(
+            legacy.session?.accounts?.find(
+              a => a.did === legacy.session?.data?.did,
+            ),
+          ),
+        })
+        logger.info(`persisted state: debug new data`, {
+          hasExistingLoggedInAccount: Boolean(newData?.session?.currentAccount),
+          numberOfExistingAccounts: newData?.session?.accounts?.length,
+          existingAccountMatchesLegacy: Boolean(
+            newData?.session?.currentAccount?.did ===
+              legacy?.session?.data?.did,
+          ),
+        })
+      } else {
+        logger.info(`persisted state: no legacy to debug, fresh install`)
+      }
+    } catch (e) {
+      logger.error(`persisted state: legacy debugging failed`, {error: e})
+    }
 
     if (!alreadyMigrated && rawLegacyData) {
       logger.info('persisted state: migrating legacy storage')