diff --git a/src/composables/useSession.js b/src/composables/useSession.js index d397d7ed9..bfe46e50d 100644 --- a/src/composables/useSession.js +++ b/src/composables/useSession.js @@ -3,30 +3,32 @@ import { useRole } from './useRole'; import { useUserConfig } from './useUserConfig'; import axios from 'axios'; import useNotify from './useNotify'; +const TOKEN_MULTIMEDIA = 'tokenMultimedia'; +const TOKEN = 'token'; export function useSession() { const { notify } = useNotify(); function getToken() { - const localToken = localStorage.getItem('token'); - const sessionToken = sessionStorage.getItem('token'); + const localToken = localStorage.getItem(TOKEN); + const sessionToken = sessionStorage.getItem(TOKEN); return localToken || sessionToken || ''; } function getTokenMultimedia() { - const localTokenMultimedia = localStorage.getItem('token'); // Temporal - const sessionTokenMultimedia = sessionStorage.getItem('token'); // Temporal + const localTokenMultimedia = localStorage.getItem(); + const sessionTokenMultimedia = sessionStorage.getItem(TOKEN_MULTIMEDIA); return localTokenMultimedia || sessionTokenMultimedia || ''; } function setToken(data) { if (data.keepLogin) { - localStorage.setItem('token', data.token); - localStorage.setItem('tokenMultimedia', data.tokenMultimedia); + localStorage.setItem(TOKEN, data.token); + localStorage.setItem(TOKEN_MULTIMEDIA, data.tokenMultimedia); } else { - sessionStorage.setItem('token', data.token); - sessionStorage.setItem('tokenMultimedia', data.tokenMultimedia); + sessionStorage.setItem(TOKEN, data.token); + sessionStorage.setItem(TOKEN_MULTIMEDIA, data.tokenMultimedia); } } async function destroyToken(url, storage, key) { @@ -71,8 +73,8 @@ export function useSession() { } function isLoggedIn() { - const localToken = localStorage.getItem('token'); - const sessionToken = sessionStorage.getItem('token'); + const localToken = localStorage.getItem(TOKEN); + const sessionToken = sessionStorage.getItem(TOKEN); return !!(localToken || sessionToken); }