diff --git a/sib-auth.js b/sib-auth.js index d6091f5650c6569e4123efda2057eca916503c84..251c50cee1a4c8201077aa031d1e9bb15e845a32 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