feat: login de emergencia admin en /adm/login y despliegue por defecto de auth unico (v3.8.5)

This commit is contained in:
2026-10-21 12:36:15 -03:00
parent 85fa1b389f
commit 836e605697
15 changed files with 540 additions and 49 deletions
+139
View File
@@ -0,0 +1,139 @@
<!DOCTYPE html>
<html lang="es" data-bs-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Consola de Emergencia - Edu-Space Admin</title>
<!-- Favicon -->
<link rel="icon" type="image/png" href="/img/favicon.png">
<!-- Script Anti-Flicker para Modo Claro / Oscuro -->
<script>
(function() {
const storedTheme = localStorage.getItem('theme');
const theme = storedTheme || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
document.documentElement.setAttribute('data-bs-theme', theme);
})();
</script>
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
<!-- Design System Theme -->
<link href="/css/theme.css" rel="stylesheet">
<style>
.admin-badge {
background: rgba(220, 53, 69, 0.15);
color: #dc3545;
border: 1px solid rgba(220, 53, 69, 0.3);
font-size: 0.72rem;
letter-spacing: 0.8px;
font-weight: 700;
text-transform: uppercase;
}
[data-bs-theme="dark"] .admin-badge {
background: rgba(248, 113, 113, 0.15);
color: #f87171;
border-color: rgba(248, 113, 113, 0.3);
}
</style>
</head>
<body>
<div class="auth-wrapper">
<div class="auth-card">
<!-- Header con Controles Superiores & Logo Oficial -->
<div class="auth-header">
<div class="auth-controls">
<button class="theme-toggle-btn" type="button" aria-label="Cambiar tema" title="Modo Claro/Oscuro">
<i class="bi bi-moon-stars-fill"></i>
</button>
</div>
<img src="/img/logo_unicaba.png" alt="UniCABA" class="auth-logo">
<div class="mt-2 mb-1">
<span class="badge admin-badge px-2 py-1 rounded-pill">
<i class="bi bi-shield-lock-fill me-1"></i>Consola Administrativa
</span>
</div>
<h4 class="fw-bold mb-1">Edu-Space Admin</h4>
<p class="text-muted small mb-0">Acceso de Contingencia y Recuperación</p>
</div>
<div class="px-4 pb-4 pt-2">
<!-- Flash Messages -->
{% if error %}
<div class="alert alert-danger alert-dismissible fade show rounded-3 py-2 small" role="alert">
<i class="bi bi-exclamation-triangle-fill me-1"></i> {{ error }}
<button type="button" class="btn-close py-2" data-bs-dismiss="alert"></button>
</div>
{% endif %}
<!-- Formulario de Autenticación de Emergencia ADMIN -->
<form action="/adm/login" method="POST" id="adminLoginForm" novalidate>
<div class="mb-3">
<label for="adminEmail" class="form-label small fw-semibold text-muted">Correo Administrador</label>
<div class="input-group">
<span class="input-group-text bg-body-tertiary border-end-0 text-muted">
<i class="bi bi-person-badge"></i>
</span>
<input type="email" class="form-control border-start-0 ps-0" id="adminEmail" name="email"
required placeholder="admin@unicaba.edu.ar" autofocus>
</div>
</div>
<div class="mb-3">
<label for="adminPassword" class="form-label small fw-semibold text-muted">Contraseña Maestra</label>
<div class="input-group">
<span class="input-group-text bg-body-tertiary border-end-0 text-muted">
<i class="bi bi-key-fill"></i>
</span>
<input type="password" class="form-control border-start-0 border-end-0 ps-0" id="adminPassword" name="password"
required placeholder="Ingresa tu clave de emergencia">
<button class="btn btn-outline-secondary border-start-0 bg-body-tertiary text-muted" type="button" id="togglePasswordBtn" title="Mostrar/Ocultar contraseña">
<i class="bi bi-eye" id="togglePasswordIcon"></i>
</button>
</div>
</div>
<div class="d-grid mb-3 mt-4">
<button type="submit" class="btn btn-danger btn-lg fw-semibold py-2">
<i class="bi bi-shield-check me-1"></i> Acceder a Consola
</button>
</div>
</form>
<div class="text-center mt-3">
<small class="text-muted d-inline-flex align-items-center" style="font-size: 0.73rem;">
<i class="bi bi-incognito text-danger me-1"></i>
Acceso restringido • Todos los intentos son registrados y auditados
</small>
<div class="mt-2">
<span class="badge bg-body-tertiary text-secondary border font-monospace" style="font-size: 0.68rem;">
<i class="bi bi-tag-fill me-1"></i>v{{ app_version or '3.8.5' }}
</span>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="/js/theme-toggle.js"></script>
<script>
// Toggle password visibility
const toggleBtn = document.getElementById('togglePasswordBtn');
const passwordInput = document.getElementById('adminPassword');
const passwordIcon = document.getElementById('togglePasswordIcon');
if (toggleBtn && passwordInput && passwordIcon) {
toggleBtn.addEventListener('click', function() {
const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
passwordInput.setAttribute('type', type);
passwordIcon.classList.toggle('bi-eye');
passwordIcon.classList.toggle('bi-eye-slash');
});
}
</script>
</body>
</html>
+3 -35
View File
@@ -117,12 +117,12 @@
{% endif %}
{% if providers.moodle %}
<button type="button" class="btn btn-moodle py-2 d-flex align-items-center justify-content-center" data-bs-toggle="collapse" data-bs-target="#moodleLoginForm">
<button type="button" class="btn btn-moodle py-2 d-flex align-items-center justify-content-center" data-bs-toggle="collapse" data-bs-target="#moodleLoginForm" aria-expanded="{{ 'true' if (is_single_provider and providers.moodle) else 'false' }}">
<i class="bi bi-mortarboard-fill me-2 fs-5"></i>
<span>Ingresar con Moodle UniCABA</span>
</button>
<div class="collapse mt-2" id="moodleLoginForm">
<div class="collapse mt-2 {{ 'show' if (is_single_provider and providers.moodle) else '' }}" id="moodleLoginForm">
<div class="card p-3 border-warning-subtle bg-body-tertiary">
<form action="/auth/moodle" method="POST">
<div class="mb-2">
@@ -142,7 +142,7 @@
{% endif %}
</div>
{% if not providers or providers.local %}
{% if (not is_single_provider) and (not providers or providers.local) and (providers.google or providers.moodle) %}
<div class="divider-text">o con credenciales locales</div>
{% endif %}
{% endif %}
@@ -181,13 +181,6 @@
</button>
</div>
</form>
{% else %}
<div class="alert alert-info py-2 px-3 small rounded-3 mb-3 text-center">
<i class="bi bi-info-circle me-1"></i>El acceso con contraseña local está deshabilitado para usuarios generales.
<div class="mt-1">
<a href="#adminEmergencyModal" data-bs-toggle="modal" class="fw-semibold text-decoration-none">Acceso de Emergencia ADMIN</a>
</div>
</div>
{% endif %}
{% if demo_access_enabled %}
@@ -232,31 +225,6 @@
</div>
</div>
</div>
<!-- Modal Acceso de Emergencia ADMIN si local está inactivo -->
<div class="modal fade" id="adminEmergencyModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-sm">
<div class="modal-content">
<div class="modal-header py-2">
<h6 class="modal-title fw-bold"><i class="bi bi-shield-exclamation text-warning me-1"></i>Acceso de Emergencia ADMIN</h6>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<form action="/auth/login" method="POST">
<div class="mb-2">
<label class="form-label small fw-semibold">Email Administrador</label>
<input type="email" name="username" class="form-control form-control-sm" required placeholder="admin@unicaba.edu.ar">
</div>
<div class="mb-3">
<label class="form-label small fw-semibold">Contraseña</label>
<input type="password" name="password" class="form-control form-control-sm" required>
</div>
<button type="submit" class="btn btn-primary btn-sm w-100 fw-semibold">Ingresar como Admin</button>
</form>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="/js/theme-toggle.js"></script>