You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by su...@apache.org on 2021/05/20 23:37:22 UTC

[superset] branch master updated: fix(sqllab): don't store user in localstorage (#14722)

This is an automated email from the ASF dual-hosted git repository.

suddjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 0e86a6b  fix(sqllab): don't store user in localstorage (#14722)
0e86a6b is described below

commit 0e86a6b81cb0916b17f8a57fcef3e2a58c343bd7
Author: David Aaron Suddjian <18...@users.noreply.github.com>
AuthorDate: Thu May 20 16:35:56 2021 -0700

    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 82132b7..857d1db 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;
+    },
   },
 };