0
0
Fork 0

refs #6930 feat: call loutMultimedia endpoint

This commit is contained in:
Javier Segarra 2024-02-28 11:28:57 +01:00
parent bddfe8f9d7
commit 0d80fd37a4
2 changed files with 31 additions and 8 deletions

View File

@ -11,7 +11,7 @@ axios.defaults.baseURL = '/api/';
const onRequest = (config) => {
const token = session.getToken();
if (token.length && config.headers) {
if (token.length && !config.headers.Authorization) {
config.headers.Authorization = token;
}

View File

@ -1,6 +1,7 @@
import { useState } from './useState';
import { useRole } from './useRole';
import { useUserConfig } from './useUserConfig';
import axios from 'axios';
export function useSession() {
@ -27,15 +28,37 @@ export function useSession() {
}
}
function destroy() {
if (localStorage.getItem('token'))
localStorage.removeItem('token')
if (localStorage.getItem('tokenMultimedia'))
async function destroy() {
if (localStorage.getItem('tokenMultimedia')){
await axios.post('VnUsers/logoutMultimedia', null, {
headers: {Authorization: localStorage.getItem('tokenMultimedia') }
});
localStorage.removeItem('tokenMultimedia')
if (sessionStorage.getItem('token'))
sessionStorage.removeItem('token');
}
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();