Merge branch 'dev' into features/ms_submodulos_worker
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
5867649d0c
|
@ -2,9 +2,11 @@ import { useState } from './useState';
|
||||||
import { useRole } from './useRole';
|
import { useRole } from './useRole';
|
||||||
import { useUserConfig } from './useUserConfig';
|
import { useUserConfig } from './useUserConfig';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import useNotify from './useNotify';
|
||||||
|
|
||||||
export function useSession() {
|
export function useSession() {
|
||||||
|
const { notify } = useNotify();
|
||||||
|
|
||||||
function getToken() {
|
function getToken() {
|
||||||
const localToken = localStorage.getItem('token');
|
const localToken = localStorage.getItem('token');
|
||||||
const sessionToken = sessionStorage.getItem('token');
|
const sessionToken = sessionStorage.getItem('token');
|
||||||
|
@ -27,38 +29,28 @@ export function useSession() {
|
||||||
sessionStorage.setItem('tokenMultimedia', data.tokenMultimedia);
|
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() {
|
async function destroy() {
|
||||||
if (localStorage.getItem('tokenMultimedia')){
|
const tokens = {
|
||||||
await axios.post('VnUsers/logoutMultimedia', null, {
|
tokenMultimedia: 'Accounts/logout',
|
||||||
headers: {Authorization: localStorage.getItem('tokenMultimedia') }
|
token: 'VnUsers/logout',
|
||||||
});
|
};
|
||||||
localStorage.removeItem('tokenMultimedia')
|
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();
|
const { setUser } = useState();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||||
|
|
||||||
describe('VnPaginate', () => {
|
describe.skip('VnPaginate', () => {
|
||||||
const expectedUrl = '/api/customers';
|
const expectedUrl = '/api/customers';
|
||||||
|
|
||||||
let vm;
|
let vm;
|
||||||
|
@ -57,13 +57,13 @@ describe('VnPaginate', () => {
|
||||||
|
|
||||||
await vm.paginate();
|
await vm.paginate();
|
||||||
|
|
||||||
expect(vm.store.skip).toEqual(3);
|
expect(vm.store.skip).toEqual(6);
|
||||||
expect(vm.store.data.length).toEqual(6);
|
expect(vm.store.data.length).toEqual(9);
|
||||||
|
|
||||||
await vm.paginate();
|
await vm.paginate();
|
||||||
|
|
||||||
expect(vm.store.skip).toEqual(6);
|
expect(vm.store.skip).toEqual(9);
|
||||||
expect(vm.store.data.length).toEqual(9);
|
expect(vm.store.data.length).toEqual(12);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue