diff --git a/public/index.html b/public/index.html
index 1c5d52a5d..e9f55f823 100644
--- a/public/index.html
+++ b/public/index.html
@@ -468,27 +468,6 @@
if (torusTheme) {
theme = torusTheme.split('-')[0]
}
- if (storageAvailable('sessionStorage')) {
- const torusWhiteLabel = sessionStorage.getItem('torus-white-label')
- if (torusWhiteLabel !== null) {
- try {
- const whiteLabelData = JSON.parse(torusWhiteLabel)
- if (whiteLabelData.theme) {
- theme = whiteLabelData.theme.isDark ? 'dark' : 'light'
- if (whiteLabelData.theme.colors && whiteLabelData.theme.colors.torusBrand1) {
- const redirectSpinner = document.querySelector('#skeleton-redirect-spinner')
- const redirectSpinnerHead = document.querySelector('#skeleton-redirect-spinner .head')
- const redirectSpinnerMask = document.querySelector('#skeleton-redirect-spinner .mask')
- redirectSpinner.style.backgroundColor = whiteLabelData.theme.colors.torusBrand1
- redirectSpinner.style.background = `conic-gradient(transparent, ${whiteLabelData.theme.colors.torusBrand1})`
- redirectSpinnerHead.style.backgroundColor = whiteLabelData.theme.colors.torusBrand1
- }
- }
- } catch (error) {
- console.error(error)
- }
- }
- }
}
if (theme === 'dark') document.querySelector('body').style.backgroundColor = '#24252A'
diff --git a/src/controllers/PreferencesController.js b/src/controllers/PreferencesController.js
index 9d5b94782..73370e5ff 100644
--- a/src/controllers/PreferencesController.js
+++ b/src/controllers/PreferencesController.js
@@ -204,20 +204,6 @@ class PreferencesController extends SafeEventEmitter {
customNfts,
customNetworks,
} = user.data || {}
- let whiteLabelLocale
-
- // White Label override
- if (config.sessionStorageAvailable) {
- let torusWhiteLabel = sessionStorage.getItem('torus-white-label')
- if (torusWhiteLabel) {
- try {
- torusWhiteLabel = JSON.parse(torusWhiteLabel)
- whiteLabelLocale = torusWhiteLabel.defaultLanguage
- } catch (error) {
- log.error(error)
- }
- }
- }
this.updateStore(
{
@@ -225,7 +211,7 @@ class PreferencesController extends SafeEventEmitter {
theme,
crashReport: Boolean(enable_crash_reporter),
selectedCurrency: defaultCurrency,
- locale: whiteLabelLocale || locale || getUserLanguage(),
+ locale: locale || getUserLanguage(),
permissions,
accountType: account_type || ACCOUNT_TYPE.NORMAL,
defaultPublicAddress: default_public_address || public_address,
diff --git a/src/handlers/Auth/OpenLoginHandler.js b/src/handlers/Auth/OpenLoginHandler.js
index 9cc7e5a99..fa945a252 100644
--- a/src/handlers/Auth/OpenLoginHandler.js
+++ b/src/handlers/Auth/OpenLoginHandler.js
@@ -7,7 +7,7 @@ import log from 'loglevel'
import config from '../../config'
import { ACCOUNT_TYPE } from '../../utils/enums'
import { get, post, put } from '../../utils/httpHelpers'
-import { generateAddressFromPrivateKey, generateTorusAuthHeaders, getIFrameOriginObject } from '../../utils/utils'
+import { generateAddressFromPrivateKey, generateTorusAuthHeaders, getIFrameOriginObject, storageUtils } from '../../utils/utils'
const getOpenloginWhitelabel = (whiteLabel = {}) => {
const whiteLabelOpenLogin = {}
@@ -70,6 +70,7 @@ class OpenLoginHandler {
network: config.torusNetwork,
no3PC: true,
_sessionNamespace: sessionNamespace || namespace,
+ storageKey: storageUtils.storageType,
})
}
diff --git a/src/store/actions.js b/src/store/actions.js
index f02a05ba3..d52ee339a 100644
--- a/src/store/actions.js
+++ b/src/store/actions.js
@@ -137,6 +137,7 @@ export default {
}
}
statusStream.write({ loggedIn: false })
+ sessionStorage.removeItem('torus-white-label')
resetStore(accountTracker.store, accountTrackerHandler)
resetStore(txController.store, transactionControllerHandler)
resetStore(assetController.store, assetControllerHandler)
diff --git a/src/store/mutations.js b/src/store/mutations.js
index 73a4a9abb..54d45d759 100644
--- a/src/store/mutations.js
+++ b/src/store/mutations.js
@@ -177,12 +177,11 @@ export default {
state.embedState = { ...state.embedState, buttonSize: payload || 56 }
},
async setWhiteLabel(state, payload) {
- if (!payload && config.sessionStorageAvailable) {
+ if (!payload) {
state.whiteLabel = {
isActive: false,
}
localThemeSet(THEME_LIGHT_BLUE_NAME, state)
- sessionStorage.removeItem('torus-white-label')
return
}
state.whiteLabel = {
@@ -192,7 +191,7 @@ export default {
}
localThemeSet(undefined, state)
// Set locale here from defaultLanguage
- if (config.sessionStorageAvailable && payload) {
+ if (payload) {
// Checks if whitelabel defaultLanguage is supported
const selectedLocale = LOCALES.find((localeInner) => localeInner.value === payload.defaultLanguage)
if (selectedLocale) {
@@ -205,8 +204,6 @@ export default {
i18n.mergeLocaleMessage(key, payload.customTranslations[key])
})
}
-
- sessionStorage.setItem('torus-white-label', JSON.stringify(payload))
}
},
setOAuthModalStatus(state, payload) {
diff --git a/src/torus.js b/src/torus.js
index d8ec758f6..9fbf01848 100644
--- a/src/torus.js
+++ b/src/torus.js
@@ -6,7 +6,7 @@ import Web3 from 'web3'
import config from './config'
import TorusController from './controllers/TorusController'
import setupMultiplex from './controllers/utils/setupMultiplex'
-import { getDefaultNetwork, getIFrameOrigin, getIFrameOriginObject, isMain } from './utils/utils'
+import { getDefaultNetwork, getIFrameOrigin, isMain, storageUtils } from './utils/utils'
// import store from './store'
let storeReference
let deferredDispatch = []
@@ -39,8 +39,7 @@ const torus = {
let sessionData
if (config.localStorageAvailable) {
- const storage = !isMain ? (config.isCustomLogin === null ? window.sessionStorage : window.localStorage) : window.localStorage
- const storageKey = config.isCustomLogin === true ? `torus_app_${getIFrameOriginObject().hostname}` : 'torus-app'
+ const { storage, storageKey } = storageUtils
sessionData = storage.getItem(storageKey)
}
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 98135962e..192b224dd 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -735,6 +735,7 @@ export const getIFrameOriginObject = () => {
export const storageUtils = {
storage: !isMain ? (config.isCustomLogin === null ? window.sessionStorage : window.localStorage) : window.localStorage,
+ storageType: !isMain ? (config.isCustomLogin === null ? 'session' : 'local') : 'local',
storageKey: config.isCustomLogin === true ? `torus_app_${config.namespace || getIFrameOriginObject().hostname}` : 'torus-app',
openloginStoreKey: config.isCustomLogin === true ? `openlogin_store_${config.namespace || getIFrameOriginObject().hostname}` : 'openlogin_store',
}