From 36dd43f73402a37d4b99368cb370d95343c81eb7 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Mon, 10 Dec 2018 14:44:12 +0000 Subject: [PATCH] Avoid preserving HS url at logout When I was talking to Matthew about this the other day, we couldn't think of a good reason why we should preserve the HS URL at logout. It introduces the problem that, if a client is redirected after login as per MSC1730, and then you log out, you'll then get a login screen for the wrong server. So basically there's no reason to have an mx_hs_url/mx_is_url without an access token, and we can remove the stuff which preserves it, and the stuff that attempts to restore it. --- src/Lifecycle.js | 9 --------- src/components/structures/MatrixChat.js | 4 ---- 2 files changed, 13 deletions(-) diff --git a/src/Lifecycle.js b/src/Lifecycle.js index f781f36fe4..ed057eb020 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -497,16 +497,7 @@ function _clearStorage() { Analytics.logout(); if (window.localStorage) { - const hsUrl = window.localStorage.getItem("mx_hs_url"); - const isUrl = window.localStorage.getItem("mx_is_url"); window.localStorage.clear(); - - // preserve our HS & IS URLs for convenience - // N.B. we cache them in hsUrl/isUrl and can't really inline them - // as getCurrentHsUrl() may call through to localStorage. - // NB. We do clear the device ID (as well as all the settings) - if (hsUrl) window.localStorage.setItem("mx_hs_url", hsUrl); - if (isUrl) window.localStorage.setItem("mx_is_url", isUrl); } // create a temporary client to clear out the persistent stores. diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 4d7c71e3ef..7feca4de45 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -204,8 +204,6 @@ export default React.createClass({ return this.state.register_hs_url; } else if (MatrixClientPeg.get()) { return MatrixClientPeg.get().getHomeserverUrl(); - } else if (window.localStorage && window.localStorage.getItem("mx_hs_url")) { - return window.localStorage.getItem("mx_hs_url"); } else { return this.getDefaultHsUrl(); } @@ -224,8 +222,6 @@ export default React.createClass({ return this.state.register_is_url; } else if (MatrixClientPeg.get()) { return MatrixClientPeg.get().getIdentityServerUrl(); - } else if (window.localStorage && window.localStorage.getItem("mx_is_url")) { - return window.localStorage.getItem("mx_is_url"); } else { return this.getDefaultIsUrl(); }