From 1e651bf1a529f0a8365d2ec820cee21966ba6467 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 15 Mar 2023 15:56:29 +0000 Subject: [PATCH] Clear electron data when logging out (#10386) --- src/BasePlatform.ts | 8 ++++++++ src/Lifecycle.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts index 7280b6bb3d..edafff229f 100644 --- a/src/BasePlatform.ts +++ b/src/BasePlatform.ts @@ -442,4 +442,12 @@ export default abstract class BasePlatform { logger.error("idbDelete failed in destroyPickleKey", e); } } + + /** + * Clear app storage, called when logging out to perform data clean up. + */ + public async clearStorage(): Promise { + window.sessionStorage.clear(); + window.localStorage.clear(); + } } diff --git a/src/Lifecycle.ts b/src/Lifecycle.ts index 5122b0a632..b1f12232a5 100644 --- a/src/Lifecycle.ts +++ b/src/Lifecycle.ts @@ -862,6 +862,7 @@ export async function onLoggedOut(): Promise { stopMatrixClient(); await clearStorage({ deleteEverything: true }); LifecycleCustomisations.onLoggedOutAndStorageCleared?.(); + await PlatformPeg.get()?.clearStorage(); // Do this last, so we can make sure all storage has been cleared and all // customisations got the memo.