From abe2b8cfd825078e97641107d00bdcfc3ea0c358 Mon Sep 17 00:00:00 2001 From: Amar Date: Tue, 11 Feb 2025 21:58:22 +0100 Subject: [PATCH 1/2] Removed map output on console --- frontend/src/components/Mappa/Mappa.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/components/Mappa/Mappa.vue b/frontend/src/components/Mappa/Mappa.vue index 9f600b1..d111098 100644 --- a/frontend/src/components/Mappa/Mappa.vue +++ b/frontend/src/components/Mappa/Mappa.vue @@ -41,7 +41,6 @@ onMounted(() => { return emergency.coordinates.lat !== null && emergency.coordinates.lon !== null; }) - console.log(filteredEmergencies) }); From 6f9ba698b5441e849d808d8689198e17341bd889 Mon Sep 17 00:00:00 2001 From: Amar Date: Tue, 11 Feb 2025 23:16:44 +0100 Subject: [PATCH 2/2] Minor password change feature + MAJOR segnala buttone (300% size) --- frontend/src/components/Mappa/Mappa.vue | 10 +++- frontend/src/views/user/ViewAccedi.vue | 5 ++ frontend/src/views/user/ViewProfilo.vue | 65 +++++++++++++++++++--- frontend/src/views/user/ViewRegistrati.vue | 1 + 4 files changed, 71 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/Mappa/Mappa.vue b/frontend/src/components/Mappa/Mappa.vue index d111098..adfa17d 100644 --- a/frontend/src/components/Mappa/Mappa.vue +++ b/frontend/src/components/Mappa/Mappa.vue @@ -69,7 +69,7 @@ onMounted(() => { - @@ -94,8 +94,12 @@ onMounted(() => { .btn-segnalazione { position: absolute; - bottom: 27px; - right: 10px; z-index: 500; + border: 2px #808080 solid; + + width: 200px; + height: 50px; + bottom: 35px; + right: 15px; } diff --git a/frontend/src/views/user/ViewAccedi.vue b/frontend/src/views/user/ViewAccedi.vue index ede918f..5800c63 100644 --- a/frontend/src/views/user/ViewAccedi.vue +++ b/frontend/src/views/user/ViewAccedi.vue @@ -79,6 +79,11 @@ onMounted(() => { createToast("info", "Accedi!", "Per visualizzare la pagina, devi prima effettuare l'accesso"); } + // Toast di reindirizzamento dopo cambio password + if (route.query.passwordChange === 'true') { + createToast("info", "Accedi!", "Dopo il cambio della password devi rieffettuare l'accesso"); + } + google.accounts.id.initialize({ client_id: import.meta.env.VITE_GOOGLE_CLIENT_ID, callback: handleCredentialResponse diff --git a/frontend/src/views/user/ViewProfilo.vue b/frontend/src/views/user/ViewProfilo.vue index 4710848..a81536a 100644 --- a/frontend/src/views/user/ViewProfilo.vue +++ b/frontend/src/views/user/ViewProfilo.vue @@ -12,8 +12,9 @@ import { reports, getMyReports } from '@/data/reports' const route = useRoute() const router = useRouter() -const password = ref() -const confirmPassword = ref() +const oldPassword = ref("") +const newPassword = ref("") +const confirmNewPassword = ref("") const showPassword = ref(false) const showToast = ref(false) @@ -63,6 +64,51 @@ function formatRole(role) { return (role === "citizen") ? "Cittadino" : "Operatore"; } +// Funzione per cambiare la password dell'utente +async function changePassword() { + if (newPassword.value.length < 8) { + createToast("warning", "Attenzione!", "Inserisci una password di almeno 8 caratteri"); + return; + } + + if (newPassword.value === "" || confirmNewPassword.value === "") { + createToast("warning", "Attenzione!", "I campi non possono essere vuoti"); + return; + } + + if (newPassword.value !== confirmNewPassword.value) { + createToast("warning", "Attenzione!", "Le password non corrispondono"); + return; + } + + try { + const apiPassword = import.meta.env.VITE_API_BASE_URL + "/users/" + + const resp = await fetch(apiPassword + loggedUser.id + "/password", { + method: 'PUT', + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${loggedUser.token}`, + }, + body: JSON.stringify({ + oldPassword: oldPassword.value, + newPassword: newPassword.value + }), + }); + + // Se il cambio password va a buon fine, effettuo il logout e reindirizzo alla pagina di login + if (resp.ok) { + clearLoggedUser(); + router.push({ path: '/accedi', query: { passwordChange: 'true' } }); + } else { + const errorData = await resp.json(); + createToast("error", "Errore!", errorData.message); + } + } catch (error) { + createToast("error", "Errore!", error.message); + } +} + function togglePasswordView() { const passwordInput = document.getElementById("passwordInput"); @@ -148,10 +194,15 @@ function createToast(type, title, msg) {

Cambia password:

-
-