From 46c1ea87e876ffd2408dfa7090bc52a14320c8ee Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Fri, 20 Aug 2021 21:48:35 +0100 Subject: [PATCH] :lock: Prevent modification of users locally --- src/utils/ConfigAccumalator.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utils/ConfigAccumalator.js b/src/utils/ConfigAccumalator.js index b92ee569..30fc6be3 100644 --- a/src/utils/ConfigAccumalator.js +++ b/src/utils/ConfigAccumalator.js @@ -24,21 +24,25 @@ export default class ConfigAccumulator { /* App Config */ appConfig() { let appConfigFile = {}; - if (this.conf) { - appConfigFile = this.conf.appConfig || {}; - } + // Set app config from file + if (this.conf) appConfigFile = this.conf.appConfig || {}; + // Fill in defaults if anything missing let usersAppConfig = defaultAppConfig; if (localStorage[localStorageKeys.APP_CONFIG]) { usersAppConfig = JSON.parse(localStorage[localStorageKeys.APP_CONFIG]); } else if (appConfigFile !== {}) { usersAppConfig = appConfigFile; } + // Some settings have their own local storage keys, apply them here usersAppConfig.layout = localStorage[localStorageKeys.LAYOUT_ORIENTATION] || appConfigFile.layout || defaultLayout; usersAppConfig.iconSize = localStorage[localStorageKeys.ICON_SIZE] || appConfigFile.iconSize || defaultIconSize; usersAppConfig.language = localStorage[localStorageKeys.LANGUAGE] || appConfigFile.language || defaultLanguage; + // Don't let users modify users locally + if (this.conf.auth) usersAppConfig.auth = appConfigFile.auth; + // All done, return final appConfig object return usersAppConfig; }