Fix mobile account session selection

This commit is contained in:
2026-06-29 22:01:41 -04:00
parent 9498a09b5b
commit b7eef743bd
9 changed files with 286 additions and 27 deletions
+14 -3
View File
@@ -66,8 +66,13 @@ export async function readStoredSessionUser(prefix: string): Promise<{
}
}
export async function migrateAuthStorage(fromPrefix: string, toPrefix: string): Promise<void> {
export async function migrateAuthStorage(
fromPrefix: string,
toPrefix: string,
options: { clearSource?: boolean } = {},
): Promise<void> {
if (fromPrefix === toPrefix) return;
const clearSource = options.clearSource ?? true;
await Promise.all(
AUTH_STORAGE_SUFFIXES.map((suffix) =>
@@ -75,7 +80,9 @@ export async function migrateAuthStorage(fromPrefix: string, toPrefix: string):
),
);
await clearAuthStorage(fromPrefix);
if (clearSource) {
await clearAuthStorage(fromPrefix);
}
}
export async function clearAuthStorage(prefix: string): Promise<void> {
@@ -124,7 +131,11 @@ export async function finalizeAuthenticatedAccount(input: {
? authStoragePrefix(input.activeAccountId)
: GUEST_AUTH_STORAGE_PREFIX;
await migrateAuthStorage(sourcePrefix, targetPrefix);
if (sourcePrefix !== targetPrefix) {
await clearAuthStorage(targetPrefix);
}
await migrateAuthStorage(sourcePrefix, targetPrefix, { clearSource: false });
await input.registerAccount({
instanceUrl: input.apiUrl,