- corretto problema ROGNOSO : Risolvere la questione "Sessioni multiple", se apro 2 browser l'ultimo va a cancellare il precedente, e mi da errore di email non valida !
Il problema era sulla fetch nel service worker, gestita in quel modo personalizzato, andava in conflitto, non tenendo le chiamate bloccanti, ma uscivano prima che arrivasse la risposta del server. - Per chi è da tanto che non si collega a RISO, compare "Email non verificata"... (si risolve chiudendo su ESCI e riloggandosi)... però andrebbe sistemata. (stesso problema di prima).
This commit is contained in:
@@ -1,61 +1,66 @@
|
||||
import type { AxiosRequestConfig, AxiosInstance, AxiosResponse } from 'axios';
|
||||
import axios from 'axios'
|
||||
import axios from 'axios';
|
||||
|
||||
// import LoginModule from '../Modules/Auth/LoginStore'
|
||||
import { toolsext } from '@src/store/Modules/toolsext'
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { tools } from '@src/store/Modules/tools'
|
||||
import * as Types from './ApiTypes'
|
||||
import { toolsext } from '@src/store/Modules/toolsext';
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants';
|
||||
import { useGlobalStore } from '@store/globalStore';
|
||||
import { useUserStore } from '@store/UserStore';
|
||||
import { tools } from '@src/store/Modules/tools';
|
||||
import * as Types from './ApiTypes';
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import { from } from 'rxjs';
|
||||
import { mergeMap, toArray } from 'rxjs/operators';
|
||||
|
||||
export let API_URL = ''
|
||||
export let API_URL = '';
|
||||
export const axiosInstance: AxiosInstance = axios.create({
|
||||
baseURL: API_URL,
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
axiosInstance.interceptors.response.use(
|
||||
});
|
||||
|
||||
/*axiosInstance.interceptors.response.use(
|
||||
(response) => {
|
||||
if (import.meta.env.VITE_DEBUG === '1') console.log(response)
|
||||
return response
|
||||
if (import.meta.env.VITE_DEBUG === '1') console.log(response);
|
||||
return response;
|
||||
},
|
||||
(error) => {
|
||||
const globalStore = useGlobalStore()
|
||||
const globalStore = useGlobalStore();
|
||||
// console.log('error', error)
|
||||
if (error.response) {
|
||||
if (import.meta.env.VITE_DEBUG === '1') console.log('Status = ', error.response.status)
|
||||
console.log('Request Error: ', error.response)
|
||||
if (import.meta.env.VITE_DEBUG === '1')
|
||||
console.log('Status = ', error.response.status);
|
||||
console.log('Request Error: ', error.response);
|
||||
if (error.response.status !== 0) {
|
||||
globalStore.setStateConnection('online')
|
||||
globalStore.setStateConnection('online');
|
||||
} else {
|
||||
globalStore.setStateConnection('offline')
|
||||
globalStore.setStateConnection('offline');
|
||||
}
|
||||
} else {
|
||||
globalStore.setStateConnection('offline')
|
||||
globalStore.setStateConnection('offline');
|
||||
}
|
||||
return Promise.reject(error)
|
||||
},
|
||||
)
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
*/
|
||||
|
||||
export const addAuthHeaders = () => {
|
||||
// axiosInstance.defaults.headers.Authorization = `Bearer ${LoginModule.userInfos.userToken}`
|
||||
}
|
||||
};
|
||||
|
||||
//export const removeAuthHeaders = () => {
|
||||
// delete axiosInstance.defaults.headers.Authorization
|
||||
//}
|
||||
|
||||
async function generateStream(path: string, payload: any, config?: RequestInit, options?: any): Promise<AsyncIterable<any>> {
|
||||
const userStore = useUserStore()
|
||||
async function generateStream(
|
||||
path: string,
|
||||
payload: any,
|
||||
config?: RequestInit,
|
||||
options?: any
|
||||
): Promise<AsyncIterable<any>> {
|
||||
const userStore = useUserStore();
|
||||
|
||||
const mieiparam: any = {
|
||||
method: 'POST',
|
||||
@@ -66,16 +71,13 @@ async function generateStream(path: string, payload: any, config?: RequestInit,
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
signal: options?.signal,
|
||||
...config
|
||||
}
|
||||
...config,
|
||||
};
|
||||
|
||||
console.log('marams: ', mieiparam)
|
||||
console.log('marams: ', mieiparam);
|
||||
|
||||
const response = await fetch(
|
||||
path,
|
||||
mieiparam,
|
||||
);
|
||||
console.log('USCITA DA FETCH... !!!!!')
|
||||
const response = await fetch(path, mieiparam);
|
||||
console.log('USCITA DA FETCH... !!!!!');
|
||||
if (response.status !== 200) throw new Error(response.status.toString());
|
||||
return getIterableStream(response);
|
||||
}
|
||||
@@ -112,17 +114,25 @@ function getIterableStream(stream: NodeJS.ReadableStream): AsyncIterable<any> {
|
||||
}
|
||||
|
||||
// Funzione helper per inviare la richiesta HTTP
|
||||
async function Request(type: string, path: string, payload: any, responsedata = {}, options: any = {}) {
|
||||
async function Request(
|
||||
type: string,
|
||||
path: string,
|
||||
payload: any,
|
||||
responsedata = {},
|
||||
options: any = {}
|
||||
) {
|
||||
const userStore = useUserStore();
|
||||
const globalStore = useGlobalStore();
|
||||
const baseURL = globalStore.getServerHost();
|
||||
|
||||
try {
|
||||
if (tools.isDebug()) console.log('Axios Request', path, type, tools.notshowPwd(payload));
|
||||
if (tools.isDebug())
|
||||
console.log('Axios Request', path, type, tools.notshowPwd(payload));
|
||||
|
||||
const isFormData = type === 'postFormData';
|
||||
const config = {
|
||||
let config: AxiosRequestConfig = {
|
||||
baseURL,
|
||||
timeout: 60000,
|
||||
headers: {
|
||||
'Content-Type': isFormData ? 'multipart/form-data' : 'application/json',
|
||||
'x-auth': userStore.x_auth_token,
|
||||
@@ -138,7 +148,7 @@ async function Request(type: string, path: string, payload: any, responsedata =
|
||||
|
||||
if (options?.stream) config.responseType = 'stream';
|
||||
|
||||
let response;
|
||||
let response: any;
|
||||
const method = type.toLowerCase();
|
||||
|
||||
// Gestione dinamica del metodo HTTP
|
||||
@@ -149,7 +159,7 @@ async function Request(type: string, path: string, payload: any, responsedata =
|
||||
return new Promise((resolve, reject) => {
|
||||
from(stream)
|
||||
.pipe(
|
||||
mergeMap(event => from([event])),
|
||||
mergeMap((event) => from([event])),
|
||||
toArray()
|
||||
)
|
||||
.subscribe(
|
||||
@@ -174,7 +184,21 @@ async function Request(type: string, path: string, payload: any, responsedata =
|
||||
response = await axiosInstance[method](path, payload, config);
|
||||
}
|
||||
} else if (['get', 'delete'].includes(method)) {
|
||||
response = await axiosInstance[method](path, {
|
||||
config.params = payload;
|
||||
config.headers = {
|
||||
...config.headers,
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
|
||||
//console.log('FACCIO LA CHIAMATA axiosInstance' + method)
|
||||
//console.log('. path', path);
|
||||
//console.log('. config', config);
|
||||
|
||||
response = await axiosInstance[method](path, config ? config : {}); // ✅ CORRETTO
|
||||
|
||||
//console.log('. USCITO DALLA CHIAMATA !', response);
|
||||
|
||||
/* response = await axiosInstance[method](path, {
|
||||
baseURL,
|
||||
params: payload,
|
||||
headers: {
|
||||
@@ -183,7 +207,8 @@ async function Request(type: string, path: string, payload: any, responsedata =
|
||||
'x-refrtok': userStore.refreshToken,
|
||||
},
|
||||
...responsedata,
|
||||
});
|
||||
});*/
|
||||
|
||||
} else if (type === 'postFormData') {
|
||||
response = await axiosInstance.post(path, payload, config);
|
||||
} else {
|
||||
@@ -191,15 +216,19 @@ async function Request(type: string, path: string, payload: any, responsedata =
|
||||
}
|
||||
|
||||
// Gestione aggiornamento token se necessario
|
||||
const setAuthToken = (path === '/updatepwd' || path === '/users/login');
|
||||
if (response && response.status === 200 && (setAuthToken || path === '/users/login')) {
|
||||
const setAuthToken = path === '/updatepwd' || path === '/users/login';
|
||||
if (
|
||||
response &&
|
||||
response.status === 200 &&
|
||||
(setAuthToken || path === '/users/login')
|
||||
) {
|
||||
const x_auth_token = String(response.headers['x-auth'] || '');
|
||||
const refreshToken = String(response.headers['x-refrtok'] || '');
|
||||
if (!x_auth_token) {
|
||||
userStore.setServerCode(toolsext.ERR_AUTHENTICATION);
|
||||
}
|
||||
if (setAuthToken) {
|
||||
userStore.UpdatePwd(x_auth_token, refreshToken);
|
||||
userStore.updatePwd(x_auth_token, refreshToken);
|
||||
localStorage.setItem(toolsext.localStorage.token, x_auth_token);
|
||||
localStorage.setItem(toolsext.localStorage.refreshToken, refreshToken);
|
||||
}
|
||||
@@ -213,28 +242,42 @@ async function Request(type: string, path: string, payload: any, responsedata =
|
||||
return new Types.AxiosSuccess(response.data, response.status);
|
||||
} catch (error) {
|
||||
// Aggiornamento asincrono dello stato di connessione (setTimeout per dare tempo a eventuali animazioni)
|
||||
console.error('Errore funzione Request', error)
|
||||
setTimeout(() => {
|
||||
if (['get'].includes(type.toLowerCase())) {
|
||||
globalStore.connData.downloading_server = (globalStore.connData.downloading_server === 1) ? -1 : globalStore.connData.downloading_server;
|
||||
globalStore.connData.downloading_server =
|
||||
globalStore.connData.downloading_server === 1
|
||||
? -1
|
||||
: globalStore.connData.downloading_server;
|
||||
} else {
|
||||
globalStore.connData.uploading_server = (globalStore.connData.uploading_server === 1) ? -1 : globalStore.connData.uploading_server;
|
||||
globalStore.connData.downloading_server = (globalStore.connData.downloading_server === 1) ? -1 : globalStore.connData.downloading_server;
|
||||
globalStore.connData.uploading_server =
|
||||
globalStore.connData.uploading_server === 1
|
||||
? -1
|
||||
: globalStore.connData.uploading_server;
|
||||
globalStore.connData.downloading_server =
|
||||
globalStore.connData.downloading_server === 1
|
||||
? -1
|
||||
: globalStore.connData.downloading_server;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
console.log('ERROR using', path);
|
||||
console.log('error.response=', error.response);
|
||||
if (error && error.response) {
|
||||
console.log('error.response=', JSON.stringify(error.response, null, 2));
|
||||
}
|
||||
}
|
||||
let mycode = 0;
|
||||
if (error.response) {
|
||||
const code = error.response.data?.code || 0;
|
||||
mycode = code;
|
||||
userStore.setServerCode(mycode);
|
||||
return Promise.reject(new Types.AxiosError(error.response.status, error.response.data, code));
|
||||
return Promise.reject(
|
||||
new Types.AxiosError(error.response.status, error.response.data, code)
|
||||
);
|
||||
}
|
||||
return Promise.reject(new Types.AxiosError(0, null, mycode, error));
|
||||
}
|
||||
}
|
||||
|
||||
export default Request
|
||||
export default Request;
|
||||
|
||||
@@ -122,10 +122,10 @@ export const Api = {
|
||||
}
|
||||
},
|
||||
|
||||
async checkTokenScaduto(status: number, evitaloop: boolean, url: string, method: string, mydata: any, setAuthToken: boolean = false) {
|
||||
async checkTokenScaduto(status: number, evitaloop: boolean, url: string, method: string, mydata: any, setAuthToken: boolean = false, statuscode2: number = 0) {
|
||||
const userStore = useUserStore();
|
||||
|
||||
if (status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED) {
|
||||
if (status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED || statuscode2 === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED) {
|
||||
try {
|
||||
console.log('Token scaduto. Tentativo di refresh...');
|
||||
const newAccessToken = await this.refreshToken();
|
||||
@@ -157,7 +157,7 @@ export const Api = {
|
||||
// Gestione di altri errori critici
|
||||
throw err2 || {status: serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN} ;
|
||||
}
|
||||
} else if (status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
} else if (status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN || statuscode2 === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
userStore.setAuth('', '');
|
||||
const $router = useRouter()
|
||||
throw { status: toolsext.ERR_RETRY_LOGIN };
|
||||
@@ -199,7 +199,7 @@ export const Api = {
|
||||
}
|
||||
|
||||
// Verifica sul token (funzione custom)
|
||||
const ret: any = await this.checkTokenScaduto(res.status, evitaloop, url, method, mydata, setAuthToken);
|
||||
const ret: any = await this.checkTokenScaduto(res.status, evitaloop, url, method, mydata, setAuthToken, res.data!.statuscode2!);
|
||||
if (ret) return ret;
|
||||
|
||||
if (tools.isDebug()) console.log(' ----> ', res);
|
||||
@@ -255,12 +255,12 @@ export const Api = {
|
||||
},
|
||||
|
||||
// Funzione che gestisce la chiamata con retry
|
||||
async SendReq(url: string, method: string, mydata: any, setAuthToken = false, evitaloop = false, retryCount = 1, retryDelay = 5000, myformdata = null, responsedata = null, options = null) {
|
||||
async SendReq(url: string, method: string, mydata: any, setAuthToken = false, evitaloop = false, retryCount = 1, retryDelay = 5000, myformdata: any = null, responsedata: any = null, options: any = null) {
|
||||
try {
|
||||
return await this.SendReqBase(url, method, mydata, setAuthToken, evitaloop, myformdata, responsedata, options);
|
||||
} catch (error) {
|
||||
// Se lo status non è 403 e sono rimasti tentativi, eseguo il retry
|
||||
const riprova = error.status !== 403 && error.status !== toolsext.ERR_RETRY_LOGIN;
|
||||
const riprova = error && error.status !== 403 && error.status !== toolsext.ERR_RETRY_LOGIN;
|
||||
if (retryCount > 0 && riprova) {
|
||||
console.log(`❌❌❌ Retrying request. Attempts remaining: ${retryCount}`);
|
||||
await this.delay(retryDelay);
|
||||
|
||||
@@ -134,6 +134,10 @@ function AddCol(params: IColGridTable) {
|
||||
path: params.path === undefined ? '' : params.path,
|
||||
onlyforAdmin: params.onlyforAdmin === undefined ? false : params.onlyforAdmin,
|
||||
dont_clone: params.dont_clone === undefined ? false : params.dont_clone,
|
||||
showifIsStatusDiPersona: params.showifIsStatusDiPersona,
|
||||
showifIsStatusOnLine: params.showifIsStatusOnLine,
|
||||
requiredifIsStatusDiPersona: params.requiredifIsStatusDiPersona,
|
||||
requiredifIsStatusOnLine: params.requiredifIsStatusOnLine,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3259,6 +3263,7 @@ export const colmyBachecas = [
|
||||
icon: 'mood',
|
||||
sortable: false,
|
||||
typeobj: 'checkbox',
|
||||
required: true,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'descr',
|
||||
@@ -3316,25 +3321,10 @@ export const colmyBachecas = [
|
||||
name: 'dateTimeStart',
|
||||
name2: 'dateTimeEnd',
|
||||
label_trans: 'event.dateTimeStart',
|
||||
// jointable: toolsext.TABCALALLDATE,
|
||||
fieldtype: costanti.FieldType.date2startend,
|
||||
// fieldtype: costanti.FieldType.select,
|
||||
// fieldtype_real: costanti.FieldType.onlydate,
|
||||
// fieldtype: costanti.FieldType.onlydate,
|
||||
icon: 'fas fa-calendar-day',
|
||||
required: true,
|
||||
}),
|
||||
/*AddCol({
|
||||
name: 'dateTimeEnd',
|
||||
label_trans: 'event.dateTimeEnd',
|
||||
fieldtype: costanti.FieldType.date,
|
||||
// jointable: toolsext.TABCALALLDATE,
|
||||
// fieldtype: costanti.FieldType.select,
|
||||
// fieldtype_real: costanti.FieldType.onlydate,
|
||||
icon: 'fas fa-calendar-day',
|
||||
sortable: false,
|
||||
required: true,
|
||||
}),*/
|
||||
AddCol({
|
||||
name: 'idCity',
|
||||
label_trans: 'skill.cityorprovince',
|
||||
@@ -3352,7 +3342,9 @@ export const colmyBachecas = [
|
||||
remote_key: '_id',
|
||||
remote_field: 'comune',
|
||||
sortable: false,
|
||||
required: true,
|
||||
requiredifIsStatusDiPersona: true,
|
||||
showifIsStatusDiPersona: true,
|
||||
showifIsStatusOnLine: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'idSector',
|
||||
@@ -3401,10 +3393,22 @@ export const colmyBachecas = [
|
||||
required: false,
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'link_conference',
|
||||
label_trans: 'reg.link_conference',
|
||||
fieldtype: costanti.FieldType.link,
|
||||
showWhen:
|
||||
costanti.showWhen.NewRec +
|
||||
costanti.showWhen.InEdit +
|
||||
costanti.showWhen.InView_OnlyifExist,
|
||||
sortable: false,
|
||||
showifIsStatusOnLine: true,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'address',
|
||||
label_trans: 'event.address',
|
||||
fieldtype: costanti.FieldType.string,
|
||||
showifIsStatusDiPersona: true,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'organisedBy',
|
||||
@@ -3431,6 +3435,7 @@ export const colmyBachecas = [
|
||||
costanti.showWhen.InView_OnlyifExist,
|
||||
sortable: false,
|
||||
isadvanced_field: true,
|
||||
showifIsStatusDiPersona: true,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'website',
|
||||
@@ -3495,14 +3500,14 @@ export const colmyBachecas = [
|
||||
fieldtype: costanti.FieldType.string,
|
||||
isadvanced_field: true,
|
||||
}),
|
||||
AddCol({
|
||||
/*AddCol({
|
||||
name: 'pub_to_share',
|
||||
label_trans: 'skill.pub_to_share',
|
||||
fieldtype: costanti.FieldType.select,
|
||||
icon: 'fas fa-users',
|
||||
jointable: 'pub_to_share',
|
||||
isadvanced_field: true,
|
||||
}),
|
||||
}),*/
|
||||
AddCol({
|
||||
name: 'date_created',
|
||||
label_trans: 'event.dateCreated',
|
||||
|
||||
@@ -8250,10 +8250,10 @@ export const tools = {
|
||||
return {
|
||||
idSector: tools.getSelectionByTable('sectors', 0, true),
|
||||
idSkill: tools.getSelectionByTable('skills', 0, true),
|
||||
idStatusSkill: tools.getSelectionByTable('statusSkills', []),
|
||||
idStatusSkill: tools.getSelectionByTable('statusSkills', [shared_consts.STATUSSKILL_DI_PERSONA]),
|
||||
idContribType: tools.getSelectionByTable('contribtypes', []),
|
||||
dateTimeStart: tools.getDateTomorrowByTime(21),
|
||||
dateTimeEnd: tools.getDateTomorrowByTime(23),
|
||||
dateTimeEnd: null,
|
||||
idCity: tools.getCitySel(),
|
||||
NumLevel: 0,
|
||||
adType: tools.getSelectionByTable('adtypes', costanti.AdType.OFFRO),
|
||||
@@ -9153,20 +9153,19 @@ export const tools = {
|
||||
// console.log('checkApp (homescreen=', globalStore.homescreen)
|
||||
|
||||
try {
|
||||
let displayMode = 'browser';
|
||||
const mqStandAlone = '(display-mode: standalone)';
|
||||
// @ts-ignore
|
||||
if (
|
||||
(navigator && navigator.standalone) ||
|
||||
window.matchMedia(mqStandAlone).matches
|
||||
) {
|
||||
// console.log('navigator.standalone')
|
||||
displayMode = 'standalone';
|
||||
}
|
||||
// prova altro 2
|
||||
// console.log('displayMode = ', displayMode)
|
||||
// Rileva iOS
|
||||
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
||||
|
||||
globalStore.isAppRunning = displayMode === 'standalone' || globalStore.homescreen;
|
||||
// Modalità standalone su iOS (Safari)
|
||||
const isStandaloneIOS = isIOS && (navigator as any).standalone === true;
|
||||
|
||||
// Modalità standalone su altri browser (Chromium, Firefox, ecc.)
|
||||
const isStandaloneOther = window.matchMedia('(display-mode: standalone)').matches;
|
||||
|
||||
const isStandalone = isStandaloneIOS || isStandaloneOther;
|
||||
|
||||
// Imposta lo stato
|
||||
globalStore.isAppRunning = isStandalone || globalStore.homescreen;
|
||||
} catch (e) {
|
||||
console.log('error navigator.standalone ?!', e);
|
||||
}
|
||||
@@ -9175,10 +9174,11 @@ export const tools = {
|
||||
try {
|
||||
// console.log('initprompt')
|
||||
const globalStore = useGlobalStore();
|
||||
console.log('ADD: beforeinstallprompt');
|
||||
|
||||
window.addEventListener('beforeinstallprompt', (event) => {
|
||||
console.log('*** ESSGUI: beforeinstallprompt');
|
||||
event.preventDefault();
|
||||
console.log('beforeinstallprompt !');
|
||||
// Stash the event so it can be triggered later.
|
||||
globalStore.deferredPrompt = event;
|
||||
|
||||
@@ -11194,7 +11194,9 @@ export const tools = {
|
||||
getmenuByPath(path: string) {
|
||||
const myroutes = static_data.routes;
|
||||
|
||||
const norm = path ? (path.startsWith('/') ? path : `/${path}`).trim().toLowerCase() : undefined;
|
||||
const norm = path
|
||||
? (path.startsWith('/') ? path : `/${path}`).trim().toLowerCase()
|
||||
: undefined;
|
||||
|
||||
const mymenus = myroutes.find((menu: any) => menu.path === norm);
|
||||
|
||||
@@ -11203,9 +11205,21 @@ export const tools = {
|
||||
return mymenus;
|
||||
},
|
||||
norm(path?: string): string | undefined {
|
||||
return typeof path === 'string' ? path.trim().replace(/^\/+|\/+$/g, '').toLowerCase() : undefined;
|
||||
return typeof path === 'string'
|
||||
? path
|
||||
.trim()
|
||||
.replace(/^\/+|\/+$/g, '')
|
||||
.toLowerCase()
|
||||
: undefined;
|
||||
},
|
||||
|
||||
isInTelegramWebView() {
|
||||
try {
|
||||
return /Telegram/.test(navigator.userAgent);
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
},
|
||||
// FINE !
|
||||
|
||||
// getLocale() {
|
||||
|
||||
@@ -191,8 +191,8 @@ export const useProducts = defineStore('Products', {
|
||||
(product: IProduct): boolean => {
|
||||
return (
|
||||
product?.arrvariazioni?.[0]?.quantita <= 0 &&
|
||||
!state.isProssimaUscitaById(product.productInfo.idStatoProdotto) &&
|
||||
!state.isPrevenditaById(product.productInfo.idStatoProdotto)
|
||||
!state.isProssimaUscitaById(product.productInfo?.idStatoProdotto) &&
|
||||
!state.isPrevenditaById(product.productInfo?.idStatoProdotto)
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1388,7 +1388,7 @@ export const useProducts = defineStore('Products', {
|
||||
const userStore = useUserStore();
|
||||
const globalStore = useGlobalStore();
|
||||
|
||||
if (!globalStore.site.confpages.enableEcommerce) return null;
|
||||
if (!globalStore.site.confpages.enableEcommerce || !tools.isLogged()) return null;
|
||||
|
||||
if (!this.userActive._id) return null;
|
||||
|
||||
@@ -2118,7 +2118,7 @@ export const useProducts = defineStore('Products', {
|
||||
break;
|
||||
case '{stato}':
|
||||
replacements[key] = this.getDescrStatiProdottoByIdStatoProdotto(
|
||||
myproduct.productInfo?.idStatoProdotto || ''
|
||||
myproduct.productInfo?.idStatoProdotto || 0
|
||||
);
|
||||
break;
|
||||
case '{scalex}':
|
||||
|
||||
@@ -991,6 +991,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
this.isLogged = false;
|
||||
this.x_auth_token = '';
|
||||
this.refreshToken = '';
|
||||
console.log('SBIANCA VUOTO ------------ x_auth_token');
|
||||
|
||||
return true;
|
||||
},
|
||||
@@ -1503,18 +1504,27 @@ export const useUserStore = defineStore('UserStore', {
|
||||
});
|
||||
},
|
||||
|
||||
UpdatePwd(x_auth_token: string, refreshToken: string) {
|
||||
updatePwd(x_auth_token: string, refreshToken: string) {
|
||||
this.x_auth_token = x_auth_token;
|
||||
console.log('SET ------------ x_auth_token', x_auth_token);
|
||||
this.refreshToken = refreshToken;
|
||||
if (!this.my.tokens) {
|
||||
this.my.tokens = [];
|
||||
}
|
||||
this.my.tokens.push({
|
||||
|
||||
const newToken = {
|
||||
access: 'auth',
|
||||
token: x_auth_token,
|
||||
refreshToken,
|
||||
data_login: tools.getDateNow(),
|
||||
});
|
||||
};
|
||||
|
||||
const index = this.my.tokens.findIndex((token) => token.access === 'auth' && token.token === x_auth_token);
|
||||
if (index === -1) {
|
||||
this.my.tokens.push(newToken);
|
||||
} else {
|
||||
this.my.tokens[index] = newToken;
|
||||
}
|
||||
},
|
||||
|
||||
setServerCode(num: number) {
|
||||
@@ -1695,7 +1705,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
tools.checkApp();
|
||||
|
||||
return Api.SendReq('/users/me/token', 'DELETE', null)
|
||||
return await Api.SendReq('/users/me/token', 'DELETE', null)
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
})
|
||||
|
||||
@@ -2223,18 +2223,18 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
if (isLogged) {
|
||||
// Fai Logout
|
||||
// console.log('Fai Logout', 'isLogged', isLogged)
|
||||
userStore.logout();
|
||||
await userStore.logout();
|
||||
this.rightDrawerOpen = true;
|
||||
return false;
|
||||
return { ris: false, status };
|
||||
} else {
|
||||
console.log('NON SONO LOGGATO... MYUSER NON TORNATO dal SRV');
|
||||
const token = localStorage.getItem(toolsext.localStorage.token);
|
||||
if (token) {
|
||||
console.log('Sbianca cmq i dati');
|
||||
// Sbianca cmq i dati
|
||||
userStore.logout();
|
||||
await userStore.logout();
|
||||
this.rightDrawerOpen = true;
|
||||
return false;
|
||||
return { ris: false, status };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2444,6 +2444,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
username: userStore.my.username,
|
||||
};
|
||||
|
||||
console.log('getStatSite')
|
||||
|
||||
return Api.SendReq('/site/load', 'POST', paramquery)
|
||||
.then((res) => {
|
||||
// console.log('datastat', res)
|
||||
|
||||
Reference in New Issue
Block a user