From 22a73737afba7876e213326532e494d58df6fc15 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 4 Aug 2023 11:29:52 -0400 Subject: [PATCH] refactor: if we have an empty key, delete local storage and flag logoutComplete as true --- src/main/bootloader/storage.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/bootloader/storage.ts b/src/main/bootloader/storage.ts index c22d3c0..42cba75 100644 --- a/src/main/bootloader/storage.ts +++ b/src/main/bootloader/storage.ts @@ -57,7 +57,12 @@ function handleStorage(event: StorageEvent) { window.addEventListener("storage", handleStorage); export function saveUserKey(key: Uint8Array) { - window.localStorage.setItem("key", bytesToHex(key)); + if (key.length) { + window.localStorage.setItem("key", bytesToHex(key)); + } else { + window.localStorage.removeItem("key"); + setLogoutComplete(true); + } const event = new StorageEvent("storage", { key: "key", });