refactor: if we have an empty key, delete local storage and flag logoutComplete as true

This commit is contained in:
Derrick Hammer 2023-08-04 11:29:52 -04:00
parent 7adc0c4072
commit 22a73737af
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 1 deletions

View File

@ -57,7 +57,12 @@ function handleStorage(event: StorageEvent) {
window.addEventListener("storage", handleStorage); window.addEventListener("storage", handleStorage);
export function saveUserKey(key: Uint8Array) { export function saveUserKey(key: Uint8Array) {
if (key.length) {
window.localStorage.setItem("key", bytesToHex(key)); window.localStorage.setItem("key", bytesToHex(key));
} else {
window.localStorage.removeItem("key");
setLogoutComplete(true);
}
const event = new StorageEvent("storage", { const event = new StorageEvent("storage", {
key: "key", key: "key",
}); });