seguir MVC en perfil

This commit is contained in:
2026-10-01 14:24:57 +02:00
parent 77e512be5b
commit f74b518d22
3 changed files with 34 additions and 15 deletions
+27 -4
View File
@@ -1,3 +1,26 @@
// COMPROBAR SESIÓN Y MOSTRAR NOMBRE/AVATAR
// (antes en perfil.php)
$.ajax({
method: "POST",
url: "controladores/controladorUsuario.php",
data: { orden: "comprobarSesion" },
}).done(function (respuesta) {
if (typeof respuesta === "string") respuesta = JSON.parse(respuesta);
if (!respuesta.activa) {
// Sin sesión: fuera de aquí
window.location.href = "index.php";
return;
}
$("#nombre").text(respuesta.usuario.nombreUsuario || "Usuario");
$("#fotoPerfil").attr(
"src",
respuesta.usuario.avatar || "img/avatars/defaultProfile.jpeg"
);
});
// =========================
// MOSTRAR ESTADISTICAS
// =========================
@@ -50,8 +73,8 @@ function cambiarNombre() {
$("#nuevoNombre").val("");
if (typeof comprobarEstadoSesion === "function") {
comprobarEstadoSesion();
if (typeof comprobarSesion === "function") {
comprobarSesion();
}
}
});
@@ -110,8 +133,8 @@ $("#inputFoto").change(function () {
);
// Actualizamos también el avatar superior en la cabecera
if (typeof comprobarEstadoSesion === "function") {
comprobarEstadoSesion();
if (typeof comprobarSesion === "function") {
comprobarSesion();
}
}
});