0
0
Fork 0

refs #6930: replace tokenUSer with tokenMultimedia

This commit is contained in:
Javier Segarra 2024-02-26 07:11:33 +01:00
parent cda0511247
commit 4af2ef49a0
17 changed files with 51 additions and 39 deletions

View File

@ -10,12 +10,12 @@ import UserPanel from 'components/UserPanel.vue';
import VnBreadcrumbs from './common/VnBreadcrumbs.vue';
const { t } = useI18n();
const session = useSession();
const stateStore = useStateStore();
const quasar = useQuasar();
const state = useState();
const user = state.getUser();
const token = session.getToken();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const appName = 'Lilium';
onMounted(() => stateStore.setMounted());

View File

@ -44,7 +44,7 @@ const darkMode = computed({
});
const user = state.getUser();
const token = session.getToken();
const token = session.getTokenMultimedia();
onMounted(async () => {
updatePreferences();

View File

@ -10,8 +10,8 @@ const $props = defineProps({
size: { type: String, default: null },
title: { type: String, default: null },
});
const session = useSession();
const token = session.getToken();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const { t } = useI18n();
const title = computed(() => $props.title ?? t('globals.system'));

View File

@ -1,8 +1,8 @@
import { useSession } from 'src/composables/useSession';
import { getUrl } from './getUrl';
const session = useSession();
const token = session.getToken();
const {getTokenMultimedia} = useSession();
const token = getTokenMultimedia();
export async function downloadFile(dmsId) {
let appUrl = await getUrl('', 'lilium');

View File

@ -10,12 +10,20 @@ export function useSession() {
return localToken || sessionToken || '';
}
function getTokenMultimedia() {
const localTokenMultimedia = localStorage.getItem('tokenMultimedia');
const sessionTokenMultimedia = sessionStorage.getItem('tokenMultimedia');
return localTokenMultimedia || sessionTokenMultimedia || '';
}
function setToken(data) {
if (data.keepLogin) {
localStorage.setItem('token', data.token);
localStorage.setItem('tokenMultimedia', data.tokenMultimedia);
} else {
sessionStorage.setItem('token', data.token);
sessionStorage.setItem('tokenMultimedia', data.tokenMultimedia);
}
}
@ -23,6 +31,9 @@ export function useSession() {
if (localStorage.getItem('token'))
localStorage.removeItem('token')
if (localStorage.getItem('tokenMultimedia'))
localStorage.removeItem('tokenMultimedia')
if (sessionStorage.getItem('token'))
sessionStorage.removeItem('token');
@ -37,8 +48,8 @@ export function useSession() {
});
}
async function login(token, keepLogin) {
setToken({ token, keepLogin });
async function login(token, tokenMultimedia, keepLogin) {
setToken({ token, tokenMultimedia, keepLogin });
await useRole().fetch();
await useUserConfig().fetch();
@ -53,6 +64,7 @@ export function useSession() {
return {
getToken,
getTokenMultimedia,
setToken,
destroy,
login,

View File

@ -13,8 +13,8 @@ import { useSession } from 'src/composables/useSession';
const route = useRoute();
const { t } = useI18n();
const session = useSession();
const token = session.getToken();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const claimFilter = {
fields: [

View File

@ -11,8 +11,8 @@ import FetchData from 'components/FetchData.vue';
const router = useRouter();
const quasar = useQuasar();
const { t } = useI18n();
const session = useSession();
const token = session.getToken();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const claimId = computed(() => router.currentRoute.value.params.id);

View File

@ -14,8 +14,8 @@ import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
const route = useRoute();
const { t } = useI18n();
const session = useSession();
const token = session.getToken();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const $props = defineProps({
id: {

View File

@ -11,8 +11,8 @@ import VnInput from 'src/components/common/VnInput.vue';
const route = useRoute();
const { t } = useI18n();
const session = useSession();
const token = session.getToken();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const workers = ref([]);
const workersCopy = ref([]);

View File

@ -15,8 +15,8 @@ import { useSession } from 'composables/useSession';
import { dashIfEmpty } from 'src/filters';
const router = useRouter();
const session = useSession();
const token = session.getToken();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const stateStore = useStateStore();
const { t } = useI18n();

View File

@ -36,7 +36,7 @@ const quasar = useQuasar();
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
const { getToken } = useSession();
const { getTokenMultimedia } = useSession();
const state = useState();
const user = state.getUser();
@ -72,7 +72,7 @@ onMounted(async () => {
});
const getItemAvatar = async () => {
const token = getToken();
const token = getTokenMultimedia();
const timeStamp = `timestamp=${Date.now()}`;
image.value = `/api/Images/catalog/200x200/${entityId.value}/download?access_token=${token}&${timeStamp}`;
};

View File

@ -11,8 +11,8 @@ import toCurrency from '../../../filters/toCurrency';
const DEFAULT_PRICE_KG = 0;
const session = useSession();
const token = session.getToken();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const { t } = useI18n();
defineProps({

View File

@ -17,9 +17,9 @@ import axios from 'axios';
const route = useRoute();
const { t } = useI18n();
const session = useSession();
const { getTokenMultimedia } = useSession();
const quasar = useQuasar();
const token = session.getToken();
const token = getTokenMultimedia();
const orderSummary = ref({
total: null,
vat: null,

View File

@ -12,8 +12,8 @@ import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy
const stateStore = useStateStore();
const { t } = useI18n();
const session = useSession();
const token = session.getToken();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const selected = ref([]);
const columns = computed(() => [

View File

@ -16,7 +16,7 @@ import RouteSearchbar from 'pages/Route/Card/RouteSearchbar.vue';
import RouteFilter from 'pages/Route/Card/RouteFilter.vue';
import RouteSummary from 'pages/Route/Card/RouteSummary.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import {useSession} from "composables/useSession";
import { useSession } from 'composables/useSession';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
const stateStore = useStateStore();
@ -144,21 +144,21 @@ const cloneRoutes = () => {
};
const showRouteReport = () => {
const ids = selectedRows.value.map(row => row?.id)
const idString = ids.join(',')
const ids = selectedRows.value.map((row) => row?.id);
const idString = ids.join(',');
let url;
if (selectedRows.value.length <= 1) {
url = `api/Routes/${idString}/driver-route-pdf?access_token=${session.getToken()}`;
url = `api/Routes/${idString}/driver-route-pdf?access_token=${session.getTokenMultimedia()}`;
} else {
const params = new URLSearchParams({
access_token: session.getToken(),
id: idString
})
access_token: session.getTokenMultimedia(),
id: idString,
});
url = `api/Routes/downloadZip?${params.toString()}`;
}
window.open(url, '_blank');
}
};
const markAsServed = () => {
selectedRows.value.forEach((row) => {

View File

@ -7,8 +7,8 @@ import VnConfirm from 'components/ui/VnConfirm.vue';
const quasar = useQuasar();
const { t } = useI18n();
const session = useSession();
const token = session.getToken();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const counters = ref({
alquilerBandeja: { count: 0, id: 96001, title: 'CC Bandeja', isTray: true },

View File

@ -22,7 +22,7 @@ const $props = defineProps({
const route = useRoute();
const { t } = useI18n();
const { getToken } = useSession();
const { getTokenMultimedia } = useSession();
const entityId = computed(() => {
return $props.id || route.params.id;
@ -56,7 +56,7 @@ const filter = {
const sip = computed(() => worker.value?.sip && worker.value.sip.extension);
function getWorkerAvatar() {
const token = getToken();
const token = getTokenMultimedia();
return `/api/Images/user/160x160/${entityId.value}/download?access_token=${token}`;
}
const data = ref(useCardDescription());