refs #6930 feat: call loutMultimedia endpoint
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

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 onRequest = (config) => {
const token = session.getToken(); const token = session.getToken();
if (token.length && config.headers) { if (token.length && !config.headers.Authorization) {
config.headers.Authorization = token; config.headers.Authorization = token;
} }

View File

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