♻️ Drop legacy browser storage on sign-in
Browsers of users of the Dexie based version still hold its token in the auth_token key of localStorage and its database named wotra, next to the per user databases of this version. resolveGate() now removes both whenever it lets the user into the app, the first open included. The removal resolves on success, error and block, like wipeLocal, and never throws, so a browser that denies storage cannot keep the user out.
This commit is contained in:
@@ -451,6 +451,20 @@ export async function wipeLocal(uid: string): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
const LEGACY_TOKEN = 'auth_token';
|
||||
const LEGACY_DB = 'wotra';
|
||||
|
||||
/** Token and database of the Dexie based app; removed on sign-in, whatever the browser allows. */
|
||||
export async function removeLegacyStorage(): Promise<void> {
|
||||
try {
|
||||
localStorage.removeItem(LEGACY_TOKEN);
|
||||
await new Promise<void>((resolve) => {
|
||||
const req = indexedDB.deleteDatabase(LEGACY_DB);
|
||||
req.onsuccess = req.onerror = req.onblocked = () => resolve();
|
||||
});
|
||||
} catch {}
|
||||
}
|
||||
|
||||
export function currentUserId(): string {
|
||||
return userId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user