diff options
author | David Lu <david.lu@hotmail.com> | 2016-06-06 10:52:57 -0700 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-06-06 13:52:57 -0400 |
commit | 26ec73d5d215f37bb0446f4721ccfea3c9f56f89 (patch) | |
tree | 082ce6b460bb6467ee306c55d2056b88d4499db7 /webapp/stores | |
parent | 1e245f19c7884e293698fe2e8cd7f46d4dac54c9 (diff) | |
download | chat-26ec73d5d215f37bb0446f4721ccfea3c9f56f89.tar.gz chat-26ec73d5d215f37bb0446f4721ccfea3c9f56f89.tar.bz2 chat-26ec73d5d215f37bb0446f4721ccfea3c9f56f89.zip |
Added error when both session and local storage are unusable (#3263)
Diffstat (limited to 'webapp/stores')
-rw-r--r-- | webapp/stores/browser_store.jsx | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/webapp/stores/browser_store.jsx b/webapp/stores/browser_store.jsx index 11fe50928..6be2dc8f3 100644 --- a/webapp/stores/browser_store.jsx +++ b/webapp/stores/browser_store.jsx @@ -1,7 +1,13 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {generateId} from 'utils/utils.jsx'; +import {browserHistory} from 'react-router'; +import * as Utils from 'utils/utils.jsx'; + +const notSupportedParams = { + title: Utils.localizeMessage('error.not_supported.title', 'Browser not supported'), + message: Utils.localizeMessage('error.not_supported.message', 'Private browsing is not supported') +}; function getPrefix() { if (global.window.mm_current_user_id) { @@ -100,7 +106,7 @@ class BrowserStoreClass { signalLogout() { if (this.isLocalStorageSupported()) { // PLT-1285 store an identifier in session storage so we can catch if the logout came from this tab on IE11 - const logoutId = generateId(); + const logoutId = Utils.generateId(); sessionStorage.setItem('__logout__', logoutId); localStorage.setItem('__logout__', logoutId); @@ -115,7 +121,7 @@ class BrowserStoreClass { signalLogin() { if (this.isLocalStorageSupported()) { // PLT-1285 store an identifier in session storage so we can catch if the logout came from this tab on IE11 - const loginId = generateId(); + const loginId = Utils.generateId(); sessionStorage.setItem('__login__', loginId); localStorage.setItem('__login__', loginId); @@ -183,9 +189,6 @@ class BrowserStoreClass { } try { - sessionStorage.setItem('__testSession__', '1'); - sessionStorage.removeItem('__testSession__'); - localStorage.setItem('__testLocal__', '1'); if (localStorage.getItem('__testLocal__') !== '1') { this.checkedLocalStorageSupported = false; @@ -197,6 +200,14 @@ class BrowserStoreClass { this.checkedLocalStorageSupported = false; } + try { + sessionStorage.setItem('__testSession__', '1'); + sessionStorage.removeItem('__testSession__'); + } catch (e) { + // Session storage not usable, website is unusable + browserHistory.push(window.location.origin + '/error?title=' + notSupportedParams.title + '&message=' + notSupportedParams.message); + } + return this.checkedLocalStorageSupported; } } |