From 1c3fbf2f90de29c936604f9c45450f1ae0cede73 Mon Sep 17 00:00:00 2001 From: marga Date: Fri, 2 Oct 2026 11:01:56 +0200 Subject: [PATCH] =?UTF-8?q?separar=20c=C3=B3digo=20para=20segur=20MVC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/cabecera.js | 15 ++++++++++++++- perfil.php | 22 +++------------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/js/cabecera.js b/js/cabecera.js index d7f8d10..a00e550 100644 --- a/js/cabecera.js +++ b/js/cabecera.js @@ -60,12 +60,25 @@ function comprobarSesion() { `; contenedor.html(htmlUsuario); + // Si estamos en la página de perfil, rellenamos nombre y foto + if ($("#nombre").length) { + $("#nombre").text(respuesta.usuario.nombreUsuario); + // ?t= evita que el navegador enseñe la foto antigua en caché + $("#fotoPerfil").attr("src", avatarUrl + "?t=" + new Date().getTime()); + } + // Si estamos en la página principal, mostramos el botón JUGAR if ($("#colBotonJugar").length) { $("#colBotonJugar").removeClass("d-none"); $("#colRanking").removeClass("col-lg-8").addClass("col-lg-7 col-xl-8"); } } else { + // Si estamos en el perfil y no hay sesión, volvemos al inicio + if ($("#nombre").length) { + window.location.href = "index.php"; + return; + } + // No hay sesión: Botones de Login y Registro const htmlInvitado = `