- fix: authenticate_withUser mancava su alcuni...

- fix: '/signin' non riproponeva il login nel caso il token fosse invalido
This commit is contained in:
Surya Paolo
2025-03-14 12:52:38 +01:00
parent d190d4800e
commit 564a621aad
17 changed files with 61 additions and 35 deletions

4
.env
View File

@@ -1,6 +1,6 @@
VITE_APP_VERSION="1.2.19"
VITE_APP_VERSION="1.2.21"
VITE_LANG_DEFAULT="it"
VITE_PAO_APP_ID="KKPPAA5KJK435J3KSS9F9D8S9F8SD98F9SDF"
VITE_SERVICE_WORKER_FILE="sw-1.2.19.js"
VITE_SERVICE_WORKER_FILE="sw-1.2.21.js"
VITE_PROJECT_ID_MAIN="5cc0a13fe5c9d156728f400a"
VITE_VUE_ROUTER_MODE="history"

View File

@@ -10,7 +10,7 @@
<meta name="description" content="<%= productDescription %>">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="version" content="1.2.19">
<meta name="version" content="1.2.21">
<meta name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width<% if (ctx.mode.cordova || ctx.mode.capacitor) { %>, viewport-fit=cover<% } %>">

View File

@@ -1,6 +1,6 @@
{
"name": "riso",
"version": "1.2.19",
"version": "1.2.21",
"description": "Siamo la Rete Italiana di Scambio Orizzontale, abbiamo creato questa piattaforma per metterla al servizio di chi vuole riscoprire il valore della condivisione e della cooperazione. Valori semplici e profondi che ci aiutano a ritrovare il Senso della Vita, perduto in questa società consumista, e riporti quei Sani Pricìpi Naturali ed Umani di Fratellanza che intere popolazioni antiche conoscevano bene.",
"productName": "Riso",
"author": "Surya",

View File

@@ -366,7 +366,7 @@ export default defineConfig((ctx) => {
// https://v2.quasar.dev/quasar-cli/developing-pwa/configuring-pwa
pwa: {
workboxMode: 'InjectManifest', // 'GenerateSW' or 'InjectManifest'
swFilename: 'sw-' + "1.2.19" + '.js',
swFilename: 'sw-' + "1.2.21" + '.js',
workboxOptions: {
swSrc: 'src-pwa/custom-service-worker.js', // Assicurati che il file esista
include: [/\.html$/, /\.js$/, /\.css$/, /\.png$/, /\.svg$/, /\.json$/], // File da precacheare

View File

@@ -1,6 +1,6 @@
{
"name": "riso",
"version": "1.2.19",
"version": "1.2.21",
"description": "Siamo la Rete Italiana di Scambio Orizzontale, abbiamo creato questa piattaforma per metterla al servizio di chi vuole riscoprire il valore della condivisione e della cooperazione. Valori semplici e profondi che ci aiutano a ritrovare il Senso della Vita, perduto in questa società consumista, e riporti quei Sani Pricìpi Naturali ed Umani di Fratellanza che intere popolazioni antiche conoscevano bene.",
"productName": "Riso",
"author": "Surya",

View File

@@ -1,6 +1,6 @@
{
"name": "gruppomacro",
"version": "1.2.19",
"version": "1.2.21",
"description": "Gruppo Macro",
"productName": "Gruppo Macro",
"author": "Surya",

View File

@@ -360,7 +360,7 @@ export default defineConfig((ctx) => {
pwa: {
workboxMode: 'InjectManifest', // 'GenerateSW' or 'InjectManifest'
swFilename: 'sw-' + "1.2.19" + '.js',
swFilename: 'sw-' + "1.2.21" + '.js',
workboxOptions: {
swSrc: 'src-pwa/custom-service-worker.js', // Assicurati che il file esista
include: [/\.html$/, /\.js$/, /\.css$/, /\.png$/, /\.svg$/, /\.json$/], // File da precacheare

View File

@@ -1,6 +1,6 @@
{
"name": "piuchebuono",
"version": "1.2.19",
"version": "1.2.21",
"description": "PiuCheBuono",
"productName": "PiuCheBuono",
"author": "Surya",

View File

@@ -360,7 +360,7 @@ export default defineConfig((ctx) => {
pwa: {
workboxMode: 'InjectManifest', // 'GenerateSW' or 'InjectManifest'
swFilename: 'sw-' + "1.2.19" + '.js',
swFilename: 'sw-' + "1.2.21" + '.js',
workboxOptions: {
swSrc: 'src-pwa/custom-service-worker.js', // Assicurati che il file esista
include: [/\.html$/, /\.js$/, /\.css$/, /\.png$/, /\.svg$/, /\.json$/], // File da precacheare

View File

@@ -1,6 +1,6 @@
{
"name": "riso",
"version": "1.2.19",
"version": "1.2.21",
"description": "Siamo la Rete Italiana di Scambio Orizzontale, abbiamo creato questa piattaforma per metterla al servizio di chi vuole riscoprire il valore della condivisione e della cooperazione. Valori semplici e profondi che ci aiutano a ritrovare il Senso della Vita, perduto in questa società consumista, e riporti quei Sani Pricìpi Naturali ed Umani di Fratellanza che intere popolazioni antiche conoscevano bene.",
"productName": "Riso",
"author": "Surya",

View File

@@ -366,7 +366,7 @@ export default defineConfig((ctx) => {
// https://v2.quasar.dev/quasar-cli/developing-pwa/configuring-pwa
pwa: {
workboxMode: 'InjectManifest', // 'GenerateSW' or 'InjectManifest'
swFilename: 'sw-' + "1.2.19" + '.js',
swFilename: 'sw-' + "1.2.21" + '.js',
workboxOptions: {
swSrc: 'src-pwa/custom-service-worker.js', // Assicurati che il file esista
include: [/\.html$/, /\.js$/, /\.css$/, /\.png$/, /\.svg$/, /\.json$/], // File da precacheare

View File

@@ -3,7 +3,7 @@
/* global workbox */
/* global cfgenv */
const VITE_APP_VERSION = "1.2.19";
const VITE_APP_VERSION = "1.2.21";
const CACHE_NAME = 'pwa-cache-' + VITE_APP_VERSION; // Nome della cache

View File

@@ -10,6 +10,7 @@ import { CFirstPageApp } from '@src/components/CFirstPageApp'
import { computed, onMounted, ref, watch } from 'vue'
import { CProvaPao } from '@src/components/CProvaPao'
import { tools } from '@tools'
import { toolsext } from '@store/Modules/toolsext'
import { Vue } from 'vue-class-component'
@@ -133,7 +134,12 @@ export default {
if (chiamaautologin) {
// console.log('CHIAMA autologin_FromLocalStorage')
await userStore.autologin_FromLocalStorage($router, $q)
const ris = await userStore.autologin_FromLocalStorage($router, $q)
if (ris?.code === toolsext.ERR_RETRY_LOGIN) {
setTimeout(() => {
$router.replace('/signin');
}, 100);
}
} else {
globalStore.finishLoading = true
}

View File

@@ -139,7 +139,8 @@ export const Api = {
} else {
// Se il refresh token fallisce, logout dell'utente
userStore.setAuth('', '');
throw { code: toolsext.ERR_AUTHENTICATION };
const $router = useRouter()
throw { code: toolsext.ERR_RETRY_LOGIN };
}
} catch (err2) {
console.error('Errore durante il refresh token:', err2);
@@ -147,12 +148,16 @@ export const Api = {
if (err2?.code === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
userStore.setServerCode(toolsext.ERR_AUTHENTICATION);
userStore.setAuth('', '');
throw { code: toolsext.ERR_AUTHENTICATION };
throw { status: toolsext.ERR_RETRY_LOGIN };
}
// Gestione di altri errori critici
throw err2;
}
} else if (status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
userStore.setAuth('', '');
const $router = useRouter()
throw { status: toolsext.ERR_RETRY_LOGIN };
}
return null;
@@ -252,7 +257,7 @@ export const Api = {
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;
const riprova = error.status !== 403 && error.status !== toolsext.ERR_RETRY_LOGIN;
if (retryCount > 0 && riprova) {
console.log(`❌❌❌ Retrying request. Attempts remaining: ${retryCount}`);
await this.delay(retryDelay);

View File

@@ -106,6 +106,7 @@ export const toolsext = {
ERR_GENERICO: -1,
ERR_SERVERFETCH: -2,
ERR_AUTHENTICATION: -5,
ERR_RETRY_LOGIN: -40,
localStorage: {

View File

@@ -1550,9 +1550,12 @@ export const useUserStore = defineStore('UserStore', {
await globalStore.checkUpdates()
}
const isok = await globalStore.loadLoginSite(router)
const { isok, stop, code } = await globalStore.loadLoginSite(router)
this.isLogged = isok && isLogged && !stop
if (!stop) {
this.isLogged = isok && isLogged
await globalStore.loadAfterLogin()
@@ -1572,10 +1575,14 @@ export const useUserStore = defineStore('UserStore', {
// console.log('$router', $router)
// document.dispatchEvent(new Event('custom-post-render-event'))
}
globalStore.finishLoading = true
if (tools.isDebug()) console.log('finishLoading', globalStore.finishLoading)
// document.dispatchEvent(new Event('custom-post-render-event'))
return { code }
} catch (e) {
console.error('Error', e)
globalStore.finishLoading = true
@@ -1623,13 +1630,13 @@ export const useUserStore = defineStore('UserStore', {
return await this.setGlobal(router, isLogged)
.then((loadstorage: any) => {
// console.log('RISULT setGlobal:', loadstorage)
if (loadstorage) {
if (loadstorage.code === 200) {
globalroutines('loadapp', '')
// Create Subscription to Push Notification
globalStore.createPushSubscription()
}
return loadstorage
})
} catch (e: any) {

View File

@@ -1019,14 +1019,18 @@ export const useGlobalStore = defineStore('GlobalStore', {
async loadLoginSite(router: Router) {
let isok = false
let code = 200
let stop = false
if (!await this.loadSite()) {
router.push('/signin')
stop = true
code = toolsext.ERR_RETRY_LOGIN
} else {
isok = true
}
return isok
return { isok, stop, code }
},
async loadAfterLogin() {
@@ -1891,8 +1895,11 @@ export const useGlobalStore = defineStore('GlobalStore', {
// userStore.setErrorCatch(error)
this.serverError = true
this.serverMsgError = error
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error)
//return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error)
return false
}
return false
},
getProvinceByProv(provstr: string) {