From e2900c210091faa5e52047b66f330cef848f2270 Mon Sep 17 00:00:00 2001 From: Amar Date: Fri, 14 Feb 2025 14:13:52 +0100 Subject: [PATCH 1/2] User cookie fix + minor bug fixes --- frontend/src/data/reports.js | 15 ++++++++-- frontend/src/states/loggedUser.js | 2 +- .../src/views/dashboard/ViewDashboard.vue | 28 +++++++++++-------- frontend/src/views/user/ViewProfilo.vue | 6 ++-- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/frontend/src/data/reports.js b/frontend/src/data/reports.js index ee18bf7..ade980f 100644 --- a/frontend/src/data/reports.js +++ b/frontend/src/data/reports.js @@ -135,10 +135,19 @@ export async function getEmailByUserId(id) { }, }); - const data = await response.json(); - return data.email; + if (response.ok) { + const data = await response.json(); + return data.email; + } else { + return null; + } } catch (error) { - console.error("Errore da getEmailByUserId(" + id + "): ", error); + if (response.status === 404) { + console.error("Utente rimosso!"); + } else { + console.error("Errore da getEmailByUserId(" + id + "): ", error); + } + return null; } } diff --git a/frontend/src/states/loggedUser.js b/frontend/src/states/loggedUser.js index daf6b8b..b5bde1a 100644 --- a/frontend/src/states/loggedUser.js +++ b/frontend/src/states/loggedUser.js @@ -35,7 +35,7 @@ function setLoggedUser(data) { loggedUser.updatedAt = data.updatedAt; // Save to cookies - Cookies.set('loggedUser', JSON.stringify(loggedUser), { expires: 7 }); // expires in 7 days + Cookies.set('loggedUser', JSON.stringify(loggedUser), { expires: 30 }); // expires in 1 month } function clearLoggedUser() { diff --git a/frontend/src/views/dashboard/ViewDashboard.vue b/frontend/src/views/dashboard/ViewDashboard.vue index ad53eaf..09f72d8 100644 --- a/frontend/src/views/dashboard/ViewDashboard.vue +++ b/frontend/src/views/dashboard/ViewDashboard.vue @@ -1,7 +1,7 @@