Compare commits

...
This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.

1 Commits

Author SHA1 Message Date
RMidhunSuresh bfd54f2764 Delete localstorage on logout 2022-08-09 23:11:02 +05:30
2 changed files with 19 additions and 0 deletions

View File

@ -451,6 +451,12 @@ export class Client {
async deleteSession(log) {
if (this._sessionId) {
await log.wrap("sessionStore", async () => {
const storage = this._storage ?? await this._platform.storageFactory.create(this._sessionId, log);
const txn = await storage.readWriteTxn([storage.storeNames.session]);
txn.session.delete();
storage.close();
});
// need to dispose first, so the storage is closed,
// and also first sync finishing won't call Session.start anymore,
// which assumes that the storage works.

View File

@ -105,4 +105,17 @@ export class SessionStore {
}
this._sessionStore.delete(key);
}
delete(): void {
const keys: string[] = [];
for (let i = 0; i < localStorage.length; i++) {
const key = this._localStorage.key(i);
if (key?.startsWith(this._localStorageKeyPrefix)) {
keys.push(key);
}
}
for (const key of keys) {
this._localStorage.removeItem(key);
}
}
}