Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

logout 2

Manav Rathi748605ff000f
diff --git a/web/apps/photos/src/services/logout.ts b/web/apps/photos/src/services/logout.ts
index 5349914fb1..517323771c 100644
--- a/web/apps/photos/src/services/logout.ts
+++ b/web/apps/photos/src/services/logout.ts
@@ -5,6 +5,7 @@ import DownloadManager from "@/new/photos/services/download";
import { logoutML, terminateMLWorker } from "@/new/photos/services/ml";
import { logoutSearch } from "@/new/photos/services/search";
import { logoutSettings } from "@/new/photos/services/settings";
+import { logoutUserDetails } from "@/new/photos/services/user";
import exportService from "./export";
/**
@@ -43,6 +44,12 @@ export const photosLogout = async () => {
ignoreError("settings", e);
}
+ try {
+ logoutUserDetails();
+ } catch (e) {
+ ignoreError("userDetails", e);
+ }
+
try {
resetUploadState();
} catch (e) {
diff --git a/web/packages/accounts/services/logout.ts b/web/packages/accounts/services/logout.ts
index 5e34a04526..1986fcd7bc 100644
--- a/web/packages/accounts/services/logout.ts
+++ b/web/packages/accounts/services/logout.ts
@@ -59,3 +59,34 @@ export const accountLogout = async () => {
ignoreError("KV DB", e);
}
};
+
+/**
+ * This is a subset of the cleanup of local persistence that has already
+ * happened during {@link accountLogout}. However, once the logout sequence is
+ * complete, we do these specific steps again to clear any state that might've
+ * been persisted meanwhile because of in-flight requests getting completed.
+ *
+ * Post this, we'll reload the page so that in-flight requests are discarded.
+ */
+export const logoutClearStateAgain = async () => {
+ const ignoreError = (label: string, e: unknown) =>
+ log.error(`Ignoring error during logout (${label})`, e);
+
+ log.info("logout (sweep)");
+
+ try {
+ clearLocalStorage();
+ } catch (e) {
+ ignoreError("Local storage", e);
+ }
+ try {
+ await localForage.clear();
+ } catch (e) {
+ ignoreError("Local forage", e);
+ }
+ try {
+ await clearKVDB();
+ } catch (e) {
+ ignoreError("KV DB", e);
+ }
+};