From 0e86a6b81cb0916b17f8a57fcef3e2a58c343bd7 Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian <1858430+suddjian@users.noreply.github.com> Date: Thu, 20 May 2021 16:35:56 -0700 Subject: [PATCH] fix(sqllab): don't store user in localstorage (#14722) * fix(sqllab): remove user info from localstorage * filter out user data when loading localstorage --- superset-frontend/src/SqlLab/App.jsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/superset-frontend/src/SqlLab/App.jsx b/superset-frontend/src/SqlLab/App.jsx index 82132b79be..857d1db408 100644 --- a/superset-frontend/src/SqlLab/App.jsx +++ b/superset-frontend/src/SqlLab/App.jsx @@ -71,6 +71,12 @@ const sqlLabPersistStateConfig = { } }); + if (subset.sqlLab?.user) { + // Don't persist the user. + // User should really not be stored under the "sqlLab" field. Oh well. + delete subset.sqlLab.user; + } + const data = JSON.stringify(subset); // 2 digit precision const currentSize = @@ -81,6 +87,16 @@ const sqlLabPersistStateConfig = { return subset; }, + merge: (initialState, persistedState = {}) => { + const result = { + ...initialState, + ...persistedState, + }; + // Filter out any user data that may have been persisted in an older version. + // Get user from bootstrap data instead, every time + result.sqlLab.user = initialState.sqlLab.user; + return result; + }, }, };