From c8eb6d7922a3203427b4e22f10a7b53bc11d7a24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com>
Date: Thu, 26 Mar 2020 15:52:32 +0100
Subject: [PATCH] update: only remove revelent entry from local storage

---
 sib-auth.js | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/sib-auth.js b/sib-auth.js
index d6091f5..251c50c 100644
--- a/sib-auth.js
+++ b/sib-auth.js
@@ -36,7 +36,7 @@ class SIBAuth extends HTMLElement {
     const timeout = session.idClaims.exp * 1000 - Date.now();
     if (timeout > 1000 * 60 * 60 * 24 * 2) return; // 2 days
     setTimeout(() => {
-      this.logout(true);
+      this.logout();
     }, timeout);
   }
 
@@ -44,7 +44,9 @@ class SIBAuth extends HTMLElement {
     if (this.session) return this.session;
     const session = await new Promise((a) => auth.trackSession(a));
     if (session && !(await this.checkServerSession(session.webId))) {
-      this.logout();
+      if ('localStorage' in window) {
+        window.localStorage.removeItem('solid-auth-client');
+      }
       return null;
     }
     this.session = session;
@@ -238,19 +240,16 @@ class SIBAuth extends HTMLElement {
    * @name logout
    * Try to logout if favorite provider is set
    */
-  logout(reload = false) {
+  logout() {
     auth
       .logout()
       .then(() => this.dispatchUserInfo())
       .then(() => {
         if ('localStorage' in window) {
-          window.localStorage.clear();
-        }
-        if ('sessionStorage' in window) {
-          window.sessionStorage.clear();
+          window.localStorage.removeItem('solid-auth-client');
         }
       })
-      .then(() => reload && window.location.reload());
+      .then(() => window.location.reload());
   }
 
   /** @function
-- 
GitLab