forked from verdnatura/salix-front
feat(lilium): refs #6930 Undo rollback lilium
This commit is contained in:
parent
dca954850b
commit
b95d44c05d
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue