diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-11-06 10:18:13 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-11-06 10:18:13 -0500 |
commit | 982162ab0df0fc84032d61009b27b92283b1a242 (patch) | |
tree | 5efe0242f0d61f11b4d16718f9cd913db85bcab3 /web/react/stores/browser_store.jsx | |
parent | 51da1b1ca1ff92fcfcdb70c46236f10ee3d20a3f (diff) | |
parent | 17cd95ae054b68a0f6816c6038f67a8901ac94d5 (diff) | |
download | chat-982162ab0df0fc84032d61009b27b92283b1a242.tar.gz chat-982162ab0df0fc84032d61009b27b92283b1a242.tar.bz2 chat-982162ab0df0fc84032d61009b27b92283b1a242.zip |
Merge pull request #1328 from mattermost/PLT-1016
PLT-1016 force logout on other browsers
Diffstat (limited to 'web/react/stores/browser_store.jsx')
-rw-r--r-- | web/react/stores/browser_store.jsx | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/web/react/stores/browser_store.jsx b/web/react/stores/browser_store.jsx index 75fb8aa3c..8e86ce32f 100644 --- a/web/react/stores/browser_store.jsx +++ b/web/react/stores/browser_store.jsx @@ -24,11 +24,17 @@ class BrowserStoreClass { this.setLastServerVersion = this.setLastServerVersion.bind(this); this.clear = this.clear.bind(this); this.clearAll = this.clearAll.bind(this); + this.checkedLocalStorageSupported = ''; + this.signalLogout = this.signalLogout.bind(this); var currentVersion = sessionStorage.getItem('storage_version'); if (currentVersion !== global.window.mm_config.Version) { sessionStorage.clear(); - sessionStorage.setItem('storage_version', global.window.mm_config.Version); + try { + sessionStorage.setItem('storage_version', global.window.mm_config.Version); + } catch (e) { + // Do nothing + } } } @@ -105,6 +111,13 @@ class BrowserStoreClass { sessionStorage.setItem('last_server_version', version); } + signalLogout() { + if (this.isLocalStorageSupported()) { + localStorage.setItem('__logout__', 'yes'); + localStorage.removeItem('__logout__'); + } + } + /** * Preforms the given action on each item that has the given prefix * Signature for action is action(key, value) @@ -147,20 +160,26 @@ class BrowserStoreClass { } isLocalStorageSupported() { + if (this.checkedLocalStorageSupported !== '') { + return this.checkedLocalStorageSupported; + } + try { - sessionStorage.setItem('testSession', '1'); - sessionStorage.removeItem('testSession'); + sessionStorage.setItem('__testSession__', '1'); + sessionStorage.removeItem('__testSession__'); - localStorage.setItem('testLocal', '1'); - if (localStorage.getItem('testLocal') !== '1') { - return false; + localStorage.setItem('__testLocal__', '1'); + if (localStorage.getItem('__testLocal__') !== '1') { + this.checkedLocalStorageSupported = false; } - localStorage.removeItem('testLocal', '1'); + localStorage.removeItem('__testLocal__', '1'); - return true; + this.checkedLocalStorageSupported = true; } catch (e) { - return false; + this.checkedLocalStorageSupported = false; } + + return this.checkedLocalStorageSupported; } } |