Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into feature/InvoicesOutCorrections
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
cb51edff04
|
@ -2,9 +2,11 @@ import { useState } from './useState';
|
|||
import { useRole } from './useRole';
|
||||
import { useUserConfig } from './useUserConfig';
|
||||
import axios from 'axios';
|
||||
|
||||
import useNotify from './useNotify';
|
||||
|
||||
export function useSession() {
|
||||
const { notify } = useNotify();
|
||||
|
||||
function getToken() {
|
||||
const localToken = localStorage.getItem('token');
|
||||
const sessionToken = sessionStorage.getItem('token');
|
||||
|
@ -27,38 +29,28 @@ export function useSession() {
|
|||
sessionStorage.setItem('tokenMultimedia', data.tokenMultimedia);
|
||||
}
|
||||
}
|
||||
|
||||
async function destroyToken(url, storage, key) {
|
||||
if (storage.getItem(key)) {
|
||||
try {
|
||||
await axios.post(url, null, {
|
||||
headers: { Authorization: storage.getItem(key) },
|
||||
});
|
||||
} catch (error) {
|
||||
notify('errors.statusUnauthorized', 'negative');
|
||||
} finally {
|
||||
storage.removeItem(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
async function destroy() {
|
||||
if (localStorage.getItem('tokenMultimedia')){
|
||||
await axios.post('VnUsers/logoutMultimedia', null, {
|
||||
headers: {Authorization: localStorage.getItem('tokenMultimedia') }
|
||||
});
|
||||
localStorage.removeItem('tokenMultimedia')
|
||||
|
||||
const tokens = {
|
||||
tokenMultimedia: 'Accounts/logout',
|
||||
token: 'VnUsers/logout',
|
||||
};
|
||||
for (const [key, url] of Object.entries(tokens)) {
|
||||
await destroyToken(url, localStorage, key);
|
||||
await destroyToken(url, sessionStorage, key);
|
||||
}
|
||||
if (localStorage.getItem('token')){
|
||||
await axios.post('VnUsers/logout', null, {
|
||||
headers: {Authorization: localStorage.getItem('token') }
|
||||
});
|
||||
localStorage.removeItem('token')
|
||||
}
|
||||
|
||||
|
||||
if (sessionStorage.getItem('tokenMultimedia')){
|
||||
await axios.post('VnUsers/logoutMultimedia', null, {
|
||||
headers: {Authorization: sessionStorage.getItem('tokenMultimedia') }
|
||||
});
|
||||
sessionStorage.removeItem('tokenMultimedia')
|
||||
|
||||
}
|
||||
if (sessionStorage.getItem('token')){
|
||||
await axios.post('VnUsers/logout', null, {
|
||||
headers: {Authorization: sessionStorage.getItem('token') }
|
||||
});
|
||||
sessionStorage.removeItem('token')
|
||||
}
|
||||
|
||||
|
||||
|
||||
const { setUser } = useState();
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ describe('VnPaginate', () => {
|
|||
],
|
||||
});
|
||||
vm.arrayData.hasMoreData.value = true;
|
||||
await vm.$nextTick();
|
||||
|
||||
vm.store.data = [
|
||||
{ id: 1, name: 'Tony Stark' },
|
||||
{ id: 2, name: 'Jessica Jones' },
|
||||
|
|
Loading…
Reference in New Issue