From c67f4927b2bbf2ec167fda17056970f8e90fa95a Mon Sep 17 00:00:00 2001 From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Date: Thu, 2 Jun 2022 15:19:57 -0500 Subject: [PATCH] Revert UI: replace localStorage with sessionStorage (#15769) * Revert UI: replace localStorage with sessionStorage * Add changelog --- changelog/15769.txt | 3 +++ ui/app/lib/local-storage.js | 8 ++++---- ui/app/lib/token-storage.js | 2 +- ui/tests/acceptance/enterprise-control-groups-test.js | 2 +- ui/tests/acceptance/redirect-to-test.js | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 changelog/15769.txt diff --git a/changelog/15769.txt b/changelog/15769.txt new file mode 100644 index 000000000..76eab0e06 --- /dev/null +++ b/changelog/15769.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Revert using localStorage in favor of sessionStorage +``` \ No newline at end of file diff --git a/ui/app/lib/local-storage.js b/ui/app/lib/local-storage.js index bc9bcfa98..86556835c 100644 --- a/ui/app/lib/local-storage.js +++ b/ui/app/lib/local-storage.js @@ -1,18 +1,18 @@ export default { getItem(key) { - var item = window.sessionStorage.getItem(key); + var item = window.localStorage.getItem(key); return item && JSON.parse(item); }, setItem(key, val) { - window.sessionStorage.setItem(key, JSON.stringify(val)); + window.localStorage.setItem(key, JSON.stringify(val)); }, removeItem(key) { - return window.sessionStorage.removeItem(key); + return window.localStorage.removeItem(key); }, keys() { - return Object.keys(window.sessionStorage); + return Object.keys(window.localStorage); }, }; diff --git a/ui/app/lib/token-storage.js b/ui/app/lib/token-storage.js index 3e8b61536..a50a5a1c3 100644 --- a/ui/app/lib/token-storage.js +++ b/ui/app/lib/token-storage.js @@ -7,7 +7,7 @@ export default function (type) { } let storage; try { - localStorageWrapper.getItem('test'); + window.localStorage.getItem('test'); storage = localStorageWrapper; } catch (e) { storage = memoryStorage; diff --git a/ui/tests/acceptance/enterprise-control-groups-test.js b/ui/tests/acceptance/enterprise-control-groups-test.js index 6589f59c1..81434e11d 100644 --- a/ui/tests/acceptance/enterprise-control-groups-test.js +++ b/ui/tests/acceptance/enterprise-control-groups-test.js @@ -173,7 +173,7 @@ module('Acceptance | Enterprise | control groups', function (hooks) { await authPage.login(context.userToken); await settled(); if (shouldStoreToken) { - sessionStorage.setItem( + localStorage.setItem( storageKey(accessor, 'kv/foo'), JSON.stringify({ accessor, diff --git a/ui/tests/acceptance/redirect-to-test.js b/ui/tests/acceptance/redirect-to-test.js index 5951301ca..698a140c9 100644 --- a/ui/tests/acceptance/redirect-to-test.js +++ b/ui/tests/acceptance/redirect-to-test.js @@ -47,7 +47,7 @@ module('Acceptance | redirect_to query param functionality', function (hooks) { // normally we'd use the auth.logout helper to visit the route and reset the app, but in this case that // also routes us to the auth page, and then all of the transitions from the auth page get redirected back // to the auth page resulting in no redirect_to query param being set - sessionStorage.clear(); + localStorage.clear(); }); test('redirect to a route after authentication', async function (assert) { let url = '/vault/secrets/secret/create';