- sistemazioni Email : registrazione, invio invito, email di benvenuto
- fix circuito - profilo
This commit is contained in:
@@ -148,8 +148,8 @@ export const Api = {
|
||||
const userStore = useUserStore();
|
||||
|
||||
if (
|
||||
status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED ||
|
||||
statuscode2 === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED
|
||||
status === serv_constants.RIS_CODE__HTTP_TOKEN_EXPIRED ||
|
||||
statuscode2 === serv_constants.RIS_CODE__HTTP_TOKEN_EXPIRED
|
||||
) {
|
||||
try {
|
||||
console.log('Token scaduto. Tentativo di refresh...');
|
||||
@@ -173,7 +173,7 @@ export const Api = {
|
||||
let mystatus = err2?.code || err2?.status;
|
||||
|
||||
if (
|
||||
mystatus === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN ||
|
||||
mystatus === serv_constants.RIS_CODE__HTTP_INVALID_TOKEN ||
|
||||
mystatus === serv_constants.RIS_CODE__HTTP_FORBIDDEN_PERMESSI ||
|
||||
mystatus === toolsext.ERR_RETRY_LOGIN
|
||||
) {
|
||||
@@ -183,12 +183,12 @@ export const Api = {
|
||||
}
|
||||
|
||||
// Gestione di altri errori critici
|
||||
throw err2 || { status: serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN };
|
||||
throw err2 || { status: serv_constants.RIS_CODE__HTTP_INVALID_TOKEN };
|
||||
}
|
||||
} else if (
|
||||
// status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN ||
|
||||
// status === serv_constants.RIS_CODE__HTTP_INVALID_TOKEN ||
|
||||
status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_PERMESSI
|
||||
// || statuscode2 === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN
|
||||
// || statuscode2 === serv_constants.RIS_CODE__HTTP_INVALID_TOKEN
|
||||
) {
|
||||
userStore.setAuth('', '');
|
||||
throw { status: toolsext.ERR_RETRY_LOGIN };
|
||||
@@ -239,10 +239,11 @@ export const Api = {
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
if (res.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
if (res.status === serv_constants.RIS_CODE__HTTP_INVALID_TOKEN) {
|
||||
userStore.setServerCode(toolsext.ERR_AUTHENTICATION);
|
||||
userStore.setAuth('', '');
|
||||
throw { code: toolsext.ERR_AUTHENTICATION };
|
||||
// throw { code: toolsext.ERR_AUTHENTICATION };
|
||||
throw { status: toolsext.ERR_RETRY_LOGIN };
|
||||
}
|
||||
|
||||
// Verifica sul token (funzione custom)
|
||||
@@ -269,6 +270,13 @@ export const Api = {
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
if (error.status === serv_constants.RIS_CODE__HTTP_INVALID_TOKEN) {
|
||||
userStore.setServerCode(toolsext.ERR_AUTHENTICATION);
|
||||
userStore.setAuth('', '');
|
||||
// throw { code: toolsext.ERR_AUTHENTICATION };
|
||||
throw { status: toolsext.ERR_RETRY_LOGIN };
|
||||
}
|
||||
|
||||
const ret: any = await this.checkTokenScaduto(
|
||||
error.status,
|
||||
evitaloop,
|
||||
@@ -341,9 +349,12 @@ export const Api = {
|
||||
options
|
||||
);
|
||||
} catch (error) {
|
||||
// Se lo status non è 403 e sono rimasti tentativi, eseguo il retry
|
||||
// Se lo status non è 403 (RIS_CODE__HTTP_FORBIDDEN_PERMESSI) e sono rimasti tentativi, eseguo il retry
|
||||
const riprova =
|
||||
error && error.status !== 403 && error.status !== toolsext.ERR_RETRY_LOGIN;
|
||||
error &&
|
||||
error.status !== serv_constants.RIS_CODE__HTTP_INVALID_TOKEN &&
|
||||
error.status !== serv_constants.RIS_CODE__HTTP_FORBIDDEN_PERMESSI &&
|
||||
error.status !== toolsext.ERR_RETRY_LOGIN;
|
||||
if (retryCount > 0 && riprova) {
|
||||
console.log(`❌❌❌ Retrying request. Attempts remaining: ${retryCount}`);
|
||||
await this.delay(retryDelay);
|
||||
|
||||
@@ -127,10 +127,9 @@ export const useCircuitStore = defineStore('CircuitStore', {
|
||||
|
||||
},
|
||||
|
||||
getFidoConcessoByUsername(myuser: IUserFields, circuitId: string, username: string): number|string {
|
||||
const userStore = useUserStore()
|
||||
getFidoConcessoByUsername(myuser: IUserFields, circuitId: string, username: string, groupname?: string): number|string {
|
||||
if (myuser && myuser.profile.useraccounts) {
|
||||
const account = myuser.profile.useraccounts.find((rec: IAccount) => rec.username === username || (rec.groupname === username && username !== '') && rec.circuitId === circuitId)
|
||||
const account = myuser.profile.useraccounts.find((rec: IAccount) => (rec.username === username || (rec.groupname === groupname && groupname !== '')) && rec.circuitId === circuitId)
|
||||
return account ? account.fidoConcesso : 0
|
||||
} else {
|
||||
return ''
|
||||
|
||||
@@ -400,7 +400,7 @@ export async function aftercalling(ris: any, checkPending: boolean, nametabindex
|
||||
if (import.meta.env.VITE_DEBUG === '1') {
|
||||
console.log('ris.status', ris.status)
|
||||
}
|
||||
if (ris.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
if (ris.status === serv_constants.RIS_CODE__HTTP_INVALID_TOKEN) {
|
||||
tools.consolelogpao('UNAUTHORIZING... TOKEN EXPIRED... !! ')
|
||||
} else {
|
||||
tools.consolelogpao('NETWORK UNREACHABLE ! (Error in fetch)', userStore.getServerCode, ris.status)
|
||||
|
||||
@@ -27,9 +27,9 @@ export const serv_constants = {
|
||||
RIS_CODE_OK: 1,
|
||||
RIS_CODE_LOGIN_OK: 1,
|
||||
RIS_ISCRIZIONE_OK: 5,
|
||||
RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN: 401,
|
||||
RIS_CODE__HTTP_INVALID_TOKEN: 401,
|
||||
RIS_CODE__HTTP_FORBIDDEN_PERMESSI: 403,
|
||||
RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED: 408,
|
||||
RIS_CODE__HTTP_TOKEN_EXPIRED: 408,
|
||||
|
||||
RIS_CODE_TOKEN_RESETPASSWORD_NOT_FOUND: -23,
|
||||
|
||||
|
||||
@@ -2720,7 +2720,7 @@ export const tools = {
|
||||
|
||||
getUserEmail() {
|
||||
const userStore = useUserStore();
|
||||
return userStore.my?.email;
|
||||
return userStore.my?.email.trim();
|
||||
},
|
||||
|
||||
getEmailSupport() {
|
||||
@@ -6375,6 +6375,32 @@ export const tools = {
|
||||
});
|
||||
});
|
||||
},
|
||||
deleteUser($q: any, username: string, usernameDest: string) {
|
||||
// Segnala Profilo
|
||||
const userStore = useUserStore();
|
||||
//T_TOLTO
|
||||
$q.dialog({
|
||||
message: t('db.domanda_deleteuser', { username: usernameDest }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda'),
|
||||
}).onOk(() => {
|
||||
userStore
|
||||
.setFriendsCmd(
|
||||
$q,
|
||||
t,
|
||||
username,
|
||||
usernameDest,
|
||||
shared_consts.FRIENDSCMD.DELETE_USER,
|
||||
null
|
||||
)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
tools.showPositiveNotif($q, t('db.deleteduser'));
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
verifyUser($q: any, username: string, usernameDest: string) {
|
||||
// Segnala Profilo
|
||||
@@ -11282,31 +11308,73 @@ export const tools = {
|
||||
.toLowerCase()
|
||||
: undefined;
|
||||
},
|
||||
isInTelegramWebView() {
|
||||
try {
|
||||
// Verifica che siamo lato client
|
||||
if (typeof window === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
isInTelegramWebView(): boolean {
|
||||
const ua = (navigator.userAgent || '').toLowerCase();
|
||||
|
||||
// Metodo 1: Controlla oggetti globali di Telegram
|
||||
const win = window as any;
|
||||
if (win.Telegram || win.TelegramWebviewProxy || win.TelegramWebApp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Metodo 2: User Agent (case-insensitive)
|
||||
const ua = navigator.userAgent.toLowerCase();
|
||||
if (ua.includes('telegram')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.error('Errore rilevamento Telegram:', e);
|
||||
return false;
|
||||
// Controlla user agent
|
||||
if (ua.includes('telegram')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Controlla oggetti globali Telegram
|
||||
const win = window as any;
|
||||
if (win.Telegram || win.TelegramWebviewProxy || win.TelegramWebApp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
isInAppBrowser(): boolean {
|
||||
const ua = (
|
||||
navigator.userAgent ||
|
||||
navigator.vendor ||
|
||||
(window as any).opera ||
|
||||
''
|
||||
).toLowerCase();
|
||||
|
||||
// Telegram specifico
|
||||
if (this.isInTelegramWebView()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Altri in-app browser
|
||||
const inAppPatterns = [
|
||||
'fbav',
|
||||
'fban', // Facebook
|
||||
'instagram', // Instagram
|
||||
'tiktok', // TikTok
|
||||
'snapchat', // Snapchat
|
||||
'twitter', // Twitter
|
||||
'line', // Line
|
||||
'micromessenger', // WeChat
|
||||
];
|
||||
|
||||
if (inAppPatterns.some((pattern) => ua.includes(pattern))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Android WebView
|
||||
if (ua.includes('wv') && ua.includes('android')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// iOS WebView (esclude Safari/Chrome/Firefox nativi)
|
||||
if (/iphone|ipad|ipod/.test(ua)) {
|
||||
const isSafari = /safari/.test(ua) && !/crios|fxios|edgios/.test(ua);
|
||||
if (!isSafari) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
isStatusNonAutorizzato() {
|
||||
const userStore = useUserStore();
|
||||
return userStore.servercode === serv_constants.RIS_CODE__HTTP_FORBIDDEN_PERMESSI
|
||||
},
|
||||
|
||||
pageExist(path: string) {
|
||||
const globalStore = useGlobalStore();
|
||||
const page = globalStore.getPage(path);
|
||||
|
||||
@@ -14,6 +14,7 @@ import type {
|
||||
IColGridTable,
|
||||
ISignupIscrizioneConacreisOptions,
|
||||
IMovQuery,
|
||||
IGroup,
|
||||
} from '@src/model';
|
||||
import { IFriends, ISettings } from '@src/model';
|
||||
import { tools } from '@tools';
|
||||
@@ -2595,5 +2596,14 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return ris.data;
|
||||
});
|
||||
},
|
||||
|
||||
getAccountGroupByCircuitId(circuitId: string, group: IMyGroup) {
|
||||
for (const circ of group.mycircuits) {
|
||||
if (circ._id === circuitId) {
|
||||
return circ.account;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2206,7 +2206,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
|
||||
userStore.updateLocalStorage(res.data.myuser);
|
||||
|
||||
isLogged = !!res.data.myuser.username;
|
||||
isLogged = !!res.data.myuser.username && res.data.myuser.email;
|
||||
} else {
|
||||
// User not exist !!
|
||||
}
|
||||
@@ -2253,8 +2253,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
if (error.status === toolsext.ERR_RETRY_LOGIN) {
|
||||
} else {
|
||||
if (
|
||||
error.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED ||
|
||||
error.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN
|
||||
error.status === serv_constants.RIS_CODE__HTTP_TOKEN_EXPIRED ||
|
||||
error.status === serv_constants.RIS_CODE__HTTP_INVALID_TOKEN
|
||||
) {
|
||||
} else {
|
||||
this.serverError = true;
|
||||
|
||||
Reference in New Issue
Block a user