Cancelar cambio de password
This commit is contained in:
@@ -12,6 +12,8 @@ $dos_factores_estado = obtenerEstadoDosFactores();
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
||||
<!-- SweetAlert2 CDN -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
|
||||
<style>
|
||||
body { font-family: 'Segoe UI', sans-serif; background-color: #f4f6f9; }
|
||||
@@ -68,6 +70,8 @@ $dos_factores_estado = obtenerEstadoDosFactores();
|
||||
.input-group { position: relative; }
|
||||
.clear-input { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #ccc; cursor: pointer; z-index: 5; display: none; }
|
||||
.clear-input:hover { color: #666; }
|
||||
/* Forzar SweetAlert2 al frente */
|
||||
.swal2-container { z-index: 11000 !important; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -137,6 +141,12 @@ $dos_factores_estado = obtenerEstadoDosFactores();
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Botón para cancelar el cambio -->
|
||||
<div class="text-center mt-2">
|
||||
<button type="button" id="btnCancelarCambio" class="btn btn-outline-danger" title="Cancelar cambio de contraseña">
|
||||
<i class="fas fa-times-circle me-1"></i> Cancelar cambio
|
||||
</button>
|
||||
</div>
|
||||
<!-- Contador de intentos -->
|
||||
<div id="intentosInfo" class="mt-2 text-center text-muted" style="font-size: 12px;">
|
||||
<!-- Se llenará dinámicamente -->
|
||||
@@ -252,7 +262,7 @@ $dos_factores_estado = obtenerEstadoDosFactores();
|
||||
const intentosInfo = document.getElementById('intentosInfo');
|
||||
|
||||
let intentosRealizados = 0;
|
||||
const maxIntentos = 3;
|
||||
const maxIntentos = 3;
|
||||
|
||||
// Auto-focus en el input al cargar
|
||||
inputCodigo.focus();
|
||||
@@ -328,7 +338,7 @@ $dos_factores_estado = obtenerEstadoDosFactores();
|
||||
}
|
||||
|
||||
// 1. SOLUCIÓN PARA EL CONTADOR DE INTENTOS
|
||||
// REEMPLAZA tu función enviarCodigo con esta versión de debug:
|
||||
// REEMPLAZA tu función enviarCodigo con esta versión de debug:
|
||||
function enviarCodigo(codigo) {
|
||||
btnVerificar.disabled = true;
|
||||
btnVerificar.classList.add('loading');
|
||||
@@ -526,7 +536,7 @@ $dos_factores_estado = obtenerEstadoDosFactores();
|
||||
this.disabled = true;
|
||||
this.innerHTML = '<i class="fas fa-spinner fa-spin me-1"></i>Enviando...';
|
||||
|
||||
fetch("/IMPORTADORES/reset/reenviarCodigo", {
|
||||
fetch("/IMPORTADORES/reset/reenviarCodigoInterno", {
|
||||
method: "POST",
|
||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||
body: "accion=reenviarCodigo"
|
||||
@@ -567,6 +577,52 @@ $dos_factores_estado = obtenerEstadoDosFactores();
|
||||
this.dispatchEvent(new Event('input'));
|
||||
});
|
||||
});
|
||||
document.getElementById('btnCancelarCambio').addEventListener('click', () => {
|
||||
Swal.fire({
|
||||
title: '¿Cancelar cambio de contraseña?',
|
||||
text: 'Se invalidará el código y se cancelará el proceso actual.',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Sí, cancelar',
|
||||
cancelButtonText: 'No, continuar'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
fetch('/IMPORTADORES/reset/cancelarCambioInterno', {
|
||||
method: 'POST'
|
||||
})
|
||||
.then(resp => resp.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Proceso cancelado',
|
||||
text: data.message,
|
||||
confirmButtonText: 'Aceptar'
|
||||
}).then(() => {
|
||||
// Redirigir al usuario
|
||||
window.location.href = '/IMPORTADORES/seguridad/index';
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Error',
|
||||
text: 'No se pudo cancelar el proceso.'
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Error al cancelar:', err);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Error',
|
||||
text: 'Ocurrió un error al intentar cancelar.'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user