about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-11-17 12:33:59 -0600
committerPaul Frazee <pfrazee@gmail.com>2022-11-17 12:33:59 -0600
commit0d70a097779716a3334811d25f04a6706e7ba38e (patch)
tree55a09f9cda8f1c8d3f62cde6883276d77de019d7 /src
parenteae5ac839c91d79fb90e7641039f7ea7656a2eac (diff)
downloadvoidsky-0d70a097779716a3334811d25f04a6706e7ba38e.tar.zst
Clear session when auth fails
Diffstat (limited to 'src')
-rw-r--r--src/state/index.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/state/index.ts b/src/state/index.ts
index 541a9a899..1ff3d3b1d 100644
--- a/src/state/index.ts
+++ b/src/state/index.ts
@@ -18,7 +18,7 @@ export async function setupState() {
 
   libapi.doPolyfill()
 
-  const api = AtpApi.service(DEFAULT_SERVICE)
+  const api = AtpApi.service(DEFAULT_SERVICE) as SessionServiceClient
   rootStore = new RootStoreModel(api)
   try {
     data = (await storage.load(ROOT_STATE_STORAGE_KEY)) || {}
@@ -28,6 +28,13 @@ export async function setupState() {
   }
 
   await rootStore.session.setup()
+  // @ts-ignore .on() is correct -prf
+  api.sessionManager.on('session', () => {
+    if (!api.sessionManager.session && rootStore.session.isAuthed) {
+      // reset session
+      rootStore.session.clear()
+    }
+  })
 
   // track changes & save to storage
   autorun(() => {