UI: Switch usage of localStorage to sessionStorage (#14054)

* Switch usage of localStorage to sessionStorage in UI

* Add changelog
This commit is contained in:
Chelsea Shaw 2022-02-17 10:04:53 -06:00 committed by GitHub
parent 10f19c66a7
commit a77899d276
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 7 deletions

3
changelog/14054.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
ui: Swap browser localStorage in favor of sessionStorage
```

View File

@ -1,18 +1,18 @@
export default {
getItem(key) {
var item = window.localStorage.getItem(key);
var item = window.sessionStorage.getItem(key);
return item && JSON.parse(item);
},
setItem(key, val) {
window.localStorage.setItem(key, JSON.stringify(val));
window.sessionStorage.setItem(key, JSON.stringify(val));
},
removeItem(key) {
return window.localStorage.removeItem(key);
return window.sessionStorage.removeItem(key);
},
keys() {
return Object.keys(window.localStorage);
return Object.keys(window.sessionStorage);
},
};

View File

@ -7,7 +7,7 @@ export default function (type) {
}
let storage;
try {
window.localStorage.getItem('test');
localStorageWrapper.getItem('test');
storage = localStorageWrapper;
} catch (e) {
storage = memoryStorage;

View File

@ -173,7 +173,7 @@ module('Acceptance | Enterprise | control groups', function (hooks) {
await authPage.login(context.userToken);
await settled();
if (shouldStoreToken) {
localStorage.setItem(
sessionStorage.setItem(
storageKey(accessor, 'kv/foo'),
JSON.stringify({
accessor,

View File

@ -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
localStorage.clear();
sessionStorage.clear();
});
test('redirect to a route after authentication', async function (assert) {
let url = '/vault/secrets/secret/create';