Add persistence to saved columns in "Hosts" table after user logs out (#1131)

- Add `removeItem` method so that we only remove the `auth_token`, and not the saved columns, from `localStorage` when the user logs out
This commit is contained in:
noahtalerman 2021-06-18 10:32:51 -04:00 committed by GitHub
parent 7859784d97
commit 0255638f0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -35,7 +35,7 @@ const authMiddleware = (store) => (next) => (action) => {
if (type === LOGOUT_SUCCESS || type === LOGIN_FAILURE) {
const { LOGIN } = PATHS;
local.clear();
local.removeItem("auth_token");
Fleet.setBearerToken(null);
store.dispatch(push(LOGIN));
}

View file

@ -16,6 +16,11 @@ const local = {
return localStorage.setItem(`FLEET::${itemName}`, value);
},
removeItem: (itemName) => {
const { localStorage } = window;
localStorage.removeItem(`FLEET::${itemName}`);
},
};
export const authToken = () => {