From 2365fbdb9c024230767cfe951c98b9124d9062fa Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 May 2019 09:51:06 +0200 Subject: [PATCH] FIXED: variable for user storage --- Globals.js | 12 ++++++++++-- Spaces/CockpitSpace.js | 5 ++--- StrategySpace/Workspace.js | 8 ++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Globals.js b/Globals.js index 7fb404879..d25a99d1c 100644 --- a/Globals.js +++ b/Globals.js @@ -122,9 +122,17 @@ function convertTimePeriodToName(pTimePeriod) { window.AT_BREAKPOINT = false; +let testUser = window.localStorage.getItem("test_user") +let LOGGED_IN_USER_LOCAL_STORAGE_KEY +let LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY -const LOGGED_IN_USER_LOCAL_STORAGE = "xuser" -const LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE = "xaccess_token" +if (testUser !== null) { + LOGGED_IN_USER_LOCAL_STORAGE_KEY = "test_user" + LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY = "test_access_token" +} else { + LOGGED_IN_USER_LOCAL_STORAGE_KEY = "user" + LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY = "access_token" +} const USDT_BTC_HTH = 19900; // This is needed to know the scale of the market time line. diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index 29096fa78..6696a400b 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -61,7 +61,7 @@ thisObject.status = 'MIDDLE' - let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE) + let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY) if (user !== null) { // Only if user is logged in thisObject.container.isDraggeable = true } else { @@ -134,7 +134,7 @@ browserCanvasContext.closePath() browserCanvasContext.fill() - let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE) + let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY) if (user !== null) { // Only if user is logged in arrow() } @@ -228,4 +228,3 @@ browserCanvasContext.stroke() } } - diff --git a/StrategySpace/Workspace.js b/StrategySpace/Workspace.js index d03cf2b35..dd9e8b5b5 100644 --- a/StrategySpace/Workspace.js +++ b/StrategySpace/Workspace.js @@ -41,9 +41,9 @@ function newWorkspace () { async function saveToStrategyzer () { try { - const accessToken = window.localStorage.getItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE) + const accessToken = window.localStorage.getItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY) - let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE) + let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY) if (user === null) { if (ERROR_LOG === true) { logger.write('[ERROR] saveToStrategyzer -> Can not save because user is not logged in. ') } return @@ -253,9 +253,9 @@ function newWorkspace () { async function loadFromStrategyzer () { try { - const accessToken = window.localStorage.getItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE) + const accessToken = window.localStorage.getItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY) - let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE) + let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY) if (user === null) { // if there is no user that means that we are logged off, which means this object can not be used. return