seguir MVC en perfil
This commit is contained in:
+2
-3
@@ -43,7 +43,7 @@ function comprobarSesion() {
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end user-dropdown-menu" aria-labelledby="userDropdown">
|
||||
<li>
|
||||
<a class="dropdown-item d-flex align-items-center gap-2" href="perfil.php">
|
||||
<a class="dropdown-item d-flex align-items-center gap-2" href="perfil.html">
|
||||
<i class="fa-solid fa-user text-primary"></i> Perfil
|
||||
</a>
|
||||
</li>
|
||||
@@ -202,5 +202,4 @@ $(document).on("click", "#botonCerrarSesion", function (event) {
|
||||
window.location.href = "index.php";
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
+27
-4
@@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user