From 37ad84f239b229ff269e09d1533908b5827c2a9e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 17 Apr 2024 10:09:44 +0200 Subject: [PATCH] perf(lilium): refs #6930 Improve setToken fn --- src/composables/useSession.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/composables/useSession.js b/src/composables/useSession.js index bfe46e50d..c7f7db24e 100644 --- a/src/composables/useSession.js +++ b/src/composables/useSession.js @@ -23,13 +23,9 @@ export function useSession() { } function setToken(data) { - if (data.keepLogin) { - localStorage.setItem(TOKEN, data.token); - localStorage.setItem(TOKEN_MULTIMEDIA, data.tokenMultimedia); - } else { - sessionStorage.setItem(TOKEN, data.token); - sessionStorage.setItem(TOKEN_MULTIMEDIA, data.tokenMultimedia); - } + const storage = data.keepLogin ? localStorage : sessionStorage; + storage.setItem(TOKEN, data.token); + storage.setItem(TOKEN_MULTIMEDIA, data.tokenMultimedia); } async function destroyToken(url, storage, key) { if (storage.getItem(key)) {