356 lines
12 KiB
HTML
356 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="es">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Iniciar sesión — KiraTV</title>
|
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,600;0,9..40,700&family=Montserrat:wght@600;700;800&display=swap" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--navy: #000066;
|
|
--navy-mid: #000044;
|
|
--gold: #e8d5b5;
|
|
--gold-hover: #f5ead8;
|
|
--text: #ffffff;
|
|
--muted: rgba(255, 255, 255, 0.72);
|
|
--border: rgba(255, 255, 255, 0.12);
|
|
}
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
margin: 0;
|
|
min-height: 100vh;
|
|
font-family: 'DM Sans', system-ui, sans-serif;
|
|
color: var(--text);
|
|
background:
|
|
radial-gradient(ellipse 100% 80% at 50% -30%, rgba(255, 255, 255, 0.06), transparent 50%),
|
|
radial-gradient(ellipse 70% 50% at 110% 40%, rgba(0, 0, 102, 0.55), transparent),
|
|
linear-gradient(165deg, var(--navy) 0%, var(--navy-mid) 100%);
|
|
}
|
|
|
|
.login-wrap {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: 100vh;
|
|
padding: 24px;
|
|
}
|
|
|
|
.login-card {
|
|
width: 100%;
|
|
max-width: 440px;
|
|
padding: 2.25rem 2rem;
|
|
border-radius: 18px;
|
|
background: rgba(0, 0, 70, 0.55);
|
|
border: 1px solid var(--border);
|
|
box-shadow:
|
|
0 24px 48px rgba(0, 0, 0, 0.45),
|
|
0 0 0 1px rgba(255, 255, 255, 0.03) inset;
|
|
backdrop-filter: blur(14px);
|
|
}
|
|
|
|
.brand-block {
|
|
text-align: center;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.login-brand-img {
|
|
display: block;
|
|
margin: 0 auto;
|
|
max-width: min(300px, 100%);
|
|
height: auto;
|
|
max-height: 220px;
|
|
object-fit: contain;
|
|
border-radius: 16px;
|
|
filter: drop-shadow(0 16px 40px rgba(0, 0, 0, 0.45));
|
|
}
|
|
|
|
.brand-tagline {
|
|
margin: 0.75rem 0 0;
|
|
font-size: 0.7rem;
|
|
font-weight: 700;
|
|
letter-spacing: 0.35em;
|
|
text-transform: uppercase;
|
|
color: var(--gold);
|
|
opacity: 0.9;
|
|
}
|
|
|
|
#login-subtitle {
|
|
margin: 0.5rem 0 0;
|
|
font-size: 0.95rem;
|
|
color: var(--muted);
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 1.1rem;
|
|
}
|
|
|
|
.form-group label {
|
|
display: block;
|
|
margin-bottom: 0.35rem;
|
|
font-size: 0.875rem;
|
|
font-weight: 600;
|
|
color: var(--text);
|
|
}
|
|
|
|
.form-group input {
|
|
width: 100%;
|
|
padding: 12px 14px;
|
|
border-radius: 10px;
|
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
background: rgba(8, 12, 20, 0.65);
|
|
color: var(--text);
|
|
font-size: 1rem;
|
|
font-family: inherit;
|
|
transition: border-color 0.2s, box-shadow 0.2s;
|
|
}
|
|
|
|
.form-group input:focus {
|
|
outline: none;
|
|
border-color: rgba(232, 213, 181, 0.5);
|
|
box-shadow: 0 0 0 3px rgba(232, 213, 181, 0.1);
|
|
}
|
|
|
|
.form-group input::placeholder {
|
|
color: rgba(168, 176, 196, 0.55);
|
|
}
|
|
|
|
.btn-login {
|
|
width: 100%;
|
|
margin-top: 0.25rem;
|
|
padding: 14px;
|
|
border: none;
|
|
border-radius: 12px;
|
|
font-size: 1rem;
|
|
font-weight: 700;
|
|
font-family: 'Montserrat', sans-serif;
|
|
cursor: pointer;
|
|
background: linear-gradient(135deg, var(--gold) 0%, #a67c1f 100%);
|
|
color: var(--navy);
|
|
transition: transform 0.15s, box-shadow 0.2s;
|
|
box-shadow: 0 4px 20px rgba(232, 213, 181, 0.18);
|
|
}
|
|
|
|
.btn-login:hover:not(:disabled) {
|
|
background: linear-gradient(135deg, var(--gold-hover) 0%, var(--gold) 100%);
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 8px 28px rgba(232, 213, 181, 0.22);
|
|
}
|
|
|
|
.btn-login:disabled {
|
|
opacity: 0.55;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
}
|
|
|
|
.error-message {
|
|
display: none;
|
|
margin-bottom: 1rem;
|
|
padding: 12px 14px;
|
|
border-radius: 10px;
|
|
font-size: 0.9rem;
|
|
background: rgba(248, 113, 113, 0.12);
|
|
border: 1px solid rgba(248, 113, 113, 0.35);
|
|
color: #fecaca;
|
|
}
|
|
|
|
.error-message.show {
|
|
display: block;
|
|
}
|
|
|
|
.setup-message {
|
|
display: none;
|
|
margin-bottom: 1rem;
|
|
padding: 12px 14px;
|
|
border-radius: 10px;
|
|
font-size: 0.9rem;
|
|
background: rgba(232, 213, 181, 0.08);
|
|
border: 1px solid rgba(232, 213, 181, 0.22);
|
|
color: var(--gold-hover);
|
|
}
|
|
|
|
.setup-message.show {
|
|
display: block;
|
|
}
|
|
|
|
.sso-divider {
|
|
text-align: center;
|
|
margin: 1.35rem 0;
|
|
position: relative;
|
|
}
|
|
|
|
.sso-divider span {
|
|
position: relative;
|
|
z-index: 1;
|
|
padding: 0 12px;
|
|
font-size: 0.8rem;
|
|
color: var(--muted);
|
|
background: rgba(15, 22, 38, 0.92);
|
|
}
|
|
|
|
.sso-divider::before {
|
|
content: '';
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
top: 50%;
|
|
height: 1px;
|
|
background: rgba(255, 255, 255, 0.08);
|
|
z-index: 0;
|
|
}
|
|
|
|
#btn-sso-login {
|
|
width: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 10px;
|
|
padding: 12px;
|
|
border-radius: 12px;
|
|
border: 1px solid rgba(255, 255, 255, 0.12);
|
|
background: transparent;
|
|
color: var(--text);
|
|
font-size: 0.95rem;
|
|
font-family: inherit;
|
|
cursor: pointer;
|
|
transition: background 0.2s, border-color 0.2s, color 0.2s;
|
|
}
|
|
|
|
#btn-sso-login:hover {
|
|
background: rgba(232, 213, 181, 0.06);
|
|
border-color: rgba(232, 213, 181, 0.35);
|
|
color: var(--gold-hover);
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="login-wrap">
|
|
<div class="login-card">
|
|
<div class="brand-block">
|
|
<img src="/img/kiratv-logo-hero.jpg" alt="KiraTV — Plataforma IPTV" width="320" height="320" decoding="async" class="login-brand-img">
|
|
<p class="brand-tagline">Plataforma IPTV</p>
|
|
<p id="login-subtitle">Inicia sesión para continuar</p>
|
|
</div>
|
|
|
|
<div class="error-message" id="error-message"></div>
|
|
<div class="setup-message" id="setup-message">
|
|
Bienvenido. Crea tu cuenta de administrador para empezar.
|
|
</div>
|
|
|
|
<form id="login-form">
|
|
<div class="form-group">
|
|
<label for="username">Usuario</label>
|
|
<input type="text" id="username" name="username" required autocomplete="username"
|
|
placeholder="Tu nombre de usuario">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="password">Contraseña</label>
|
|
<input type="password" id="password" name="password" required autocomplete="current-password"
|
|
minlength="6" placeholder="Tu contraseña">
|
|
</div>
|
|
|
|
<button type="submit" class="btn-login" id="submit-btn">Entrar</button>
|
|
</form>
|
|
|
|
<div class="sso-divider">
|
|
<span>o</span>
|
|
</div>
|
|
|
|
<button type="button" id="btn-sso-login">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" style="width:20px;height:20px;">
|
|
<path d="M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm-2 16l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z" />
|
|
</svg>
|
|
Entrar con SSO
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById('btn-sso-login').addEventListener('click', () => {
|
|
window.location.href = '/api/auth/oidc/login';
|
|
});
|
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const error = urlParams.get('error');
|
|
if (error) {
|
|
const errorMessage = document.getElementById('error-message');
|
|
errorMessage.textContent = error;
|
|
errorMessage.classList.add('show');
|
|
window.history.replaceState({}, document.title, window.location.pathname);
|
|
}
|
|
|
|
let isSetupMode = false;
|
|
|
|
async function checkSetupRequired() {
|
|
try {
|
|
const response = await fetch('/api/auth/setup-required');
|
|
const data = await response.json();
|
|
|
|
if (data.setupRequired) {
|
|
isSetupMode = true;
|
|
document.getElementById('login-subtitle').textContent = 'Crea la cuenta de administrador';
|
|
document.getElementById('submit-btn').textContent = 'Crear cuenta';
|
|
document.getElementById('setup-message').classList.add('show');
|
|
document.getElementById('password').placeholder = 'Mínimo 6 caracteres';
|
|
document.querySelector('.sso-divider').style.display = 'none';
|
|
document.getElementById('btn-sso-login').style.display = 'none';
|
|
}
|
|
} catch (err) {
|
|
console.error('Error checking setup status:', err);
|
|
}
|
|
}
|
|
|
|
document.getElementById('login-form').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
const submitBtn = document.getElementById('submit-btn');
|
|
const errorMessage = document.getElementById('error-message');
|
|
|
|
errorMessage.classList.remove('show');
|
|
errorMessage.textContent = '';
|
|
|
|
submitBtn.disabled = true;
|
|
submitBtn.textContent = 'Espera…';
|
|
|
|
try {
|
|
const endpoint = isSetupMode ? '/api/auth/setup' : '/api/auth/login';
|
|
const response = await fetch(endpoint, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ username, password })
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (!response.ok) {
|
|
throw new Error(data.error || 'Error de autenticación');
|
|
}
|
|
|
|
localStorage.setItem('authToken', data.token);
|
|
window.location.replace('/');
|
|
} catch (err) {
|
|
errorMessage.textContent = err.message;
|
|
errorMessage.classList.add('show');
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = isSetupMode ? 'Crear cuenta' : 'Entrar';
|
|
}
|
|
});
|
|
|
|
checkSetupRequired();
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|