320 lines
12 KiB
HTML
320 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="stylesheet" href="css/main.css">
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
background: var(--color-bg-primary);
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
|
}
|
|
|
|
.login-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
|
|
.login-box {
|
|
background: var(--color-bg-secondary);
|
|
padding: var(--space-2xl);
|
|
border-radius: var(--radius-lg);
|
|
box-shadow: var(--shadow-lg);
|
|
width: 100%;
|
|
max-width: 420px;
|
|
border: 1px solid var(--color-border);
|
|
}
|
|
|
|
.login-logo {
|
|
text-align: center;
|
|
margin-bottom: var(--space-2xl);
|
|
}
|
|
|
|
.login-logo .logo-icon {
|
|
width: 64px;
|
|
height: 64px;
|
|
margin: 0 auto var(--space-md);
|
|
color: var(--color-accent);
|
|
}
|
|
|
|
.login-logo h1 {
|
|
font-family: 'Century Gothic', sans-serif;
|
|
font-size: 28px;
|
|
font-weight: 500;
|
|
color: var(--color-text-primary);
|
|
margin: 0;
|
|
}
|
|
|
|
.login-logo .brand-accent {
|
|
color: var(--color-accent);
|
|
}
|
|
|
|
.login-logo p {
|
|
color: var(--color-text-secondary);
|
|
margin: var(--space-sm) 0 0 0;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: var(--space-lg);
|
|
}
|
|
|
|
.form-group label {
|
|
display: block;
|
|
margin-bottom: var(--space-sm);
|
|
color: var(--color-text-primary);
|
|
font-weight: 500;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.form-group input {
|
|
width: 100%;
|
|
padding: 12px 16px;
|
|
background: var(--color-bg-tertiary);
|
|
border: 1px solid var(--color-border);
|
|
border-radius: var(--radius-md);
|
|
color: var(--color-text-primary);
|
|
font-size: 15px;
|
|
font-family: 'Outfit', sans-serif;
|
|
transition: all 0.2s;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.form-group input:focus {
|
|
outline: none;
|
|
border-color: var(--color-accent);
|
|
background: var(--color-bg-hover);
|
|
}
|
|
|
|
.form-group input::placeholder {
|
|
color: var(--color-text-muted);
|
|
}
|
|
|
|
.btn-login {
|
|
width: 100%;
|
|
padding: 14px;
|
|
background: var(--color-accent);
|
|
color: white;
|
|
border: none;
|
|
border-radius: var(--radius-md);
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
font-family: 'Outfit', sans-serif;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.btn-login:hover {
|
|
background: var(--color-accent-hover);
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
|
|
}
|
|
|
|
.btn-login:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.btn-login:disabled {
|
|
opacity: 0.5;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
}
|
|
|
|
.error-message {
|
|
background: rgba(239, 68, 68, 0.1);
|
|
color: var(--color-error);
|
|
padding: 12px 16px;
|
|
border-radius: var(--radius-md);
|
|
margin-bottom: var(--space-lg);
|
|
border: 1px solid rgba(239, 68, 68, 0.2);
|
|
font-size: 14px;
|
|
display: none;
|
|
}
|
|
|
|
.error-message.show {
|
|
display: block;
|
|
}
|
|
|
|
.setup-message {
|
|
background: rgba(99, 102, 241, 0.1);
|
|
color: var(--color-accent);
|
|
padding: 12px 16px;
|
|
border-radius: var(--radius-md);
|
|
margin-bottom: var(--space-lg);
|
|
border: 1px solid var(--color-accent-dim);
|
|
font-size: 14px;
|
|
display: none;
|
|
}
|
|
|
|
.setup-message.show {
|
|
display: block;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="login-container">
|
|
<div class="login-box">
|
|
<div class="login-logo">
|
|
<svg class="logo-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 187.63 210.6"
|
|
fill="currentColor">
|
|
<path
|
|
d="M169.71,87.87c-4.77,0-9.1,1.88-12.31,4.92L35.3,22.3c.35-1.4.56-2.86.56-4.37C35.86,8.03,27.83,0,17.93,0S0,8.03,0,17.93c0,8.44,5.84,15.5,13.69,17.4v140c-7.71,2.01-13.41,8.99-13.41,17.33,0,9.9,8.03,17.93,17.93,17.93s17.93-8.03,17.93-17.93c0-1.56-.22-3.07-.6-4.51l121.21-69.98c3.26,3.42,7.86,5.55,12.95,5.55,9.9,0,17.93-8.03,17.93-17.93s-8.03-17.93-17.93-17.93ZM152.78,99.92c-.14.41-.27.83-.38,1.25h-51.47l-44.18-24.72L30.4,30.8c.33-.32.64-.65.94-.99l121.45,70.12ZM22.17,175.2V35.33c.23-.05.45-.11.67-.17l26.35,45.65-.34,50.04-25.74,44.59c-.31-.09-.63-.17-.95-.24ZM31.52,180.69c-.27-.3-.55-.6-.84-.89l25.48-44.13,44.64-25.78h51.47c.07.32.15.63.24.94L31.52,180.69Z" />
|
|
</svg>
|
|
<h1>KiraTV</h1>
|
|
<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">Username</label>
|
|
<input type="text" id="username" name="username" required autocomplete="username"
|
|
placeholder="Enter your username">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="password">Password</label>
|
|
<input type="password" id="password" name="password" required autocomplete="current-password"
|
|
minlength="6" placeholder="Enter your password">
|
|
</div>
|
|
|
|
<button type="submit" class="btn-login" id="submit-btn">Sign In</button>
|
|
</form>
|
|
|
|
<div class="sso-divider" style="text-align: center; margin: 20px 0; position: relative;">
|
|
<span
|
|
style="background: var(--color-bg-secondary); padding: 0 10px; color: var(--color-text-secondary); font-size: 14px; position: relative; z-index: 1;">OR</span>
|
|
<div
|
|
style="position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--color-border); z-index: 0;">
|
|
</div>
|
|
</div>
|
|
|
|
<button id="btn-sso-login" class="btn-login"
|
|
style="background: transparent; border: 1px solid var(--color-border); color: var(--color-text-primary); display: flex; align-items: center; justify-content: center; gap: 10px; transition: all 0.2s;">
|
|
<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>
|
|
Sign in with SSO
|
|
</button>
|
|
|
|
<style>
|
|
#btn-sso-login:hover {
|
|
background: var(--color-bg-tertiary) !important;
|
|
border-color: var(--color-accent) !important;
|
|
color: var(--color-accent) !important;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
}
|
|
</style>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Start SSO Login
|
|
document.getElementById('btn-sso-login').addEventListener('click', () => {
|
|
window.location.href = '/api/auth/oidc/login';
|
|
});
|
|
|
|
// Check for URL Error params
|
|
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');
|
|
// Clean URL
|
|
window.history.replaceState({}, document.title, window.location.pathname);
|
|
}
|
|
|
|
// Check if setup is required
|
|
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 = 'Create Admin Account';
|
|
document.getElementById('submit-btn').textContent = 'Create Account';
|
|
document.getElementById('setup-message').classList.add('show');
|
|
document.getElementById('password').placeholder = 'Minimum 6 characters';
|
|
// Hide SSO in setup mode
|
|
document.querySelector('.sso-divider').style.display = 'none';
|
|
document.getElementById('btn-sso-login').style.display = 'none';
|
|
}
|
|
} catch (err) {
|
|
console.error('Error checking setup status:', err);
|
|
}
|
|
}
|
|
|
|
// Handle form submission
|
|
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');
|
|
|
|
// Clear previous errors
|
|
errorMessage.classList.remove('show');
|
|
errorMessage.textContent = '';
|
|
|
|
// Disable button
|
|
submitBtn.disabled = true;
|
|
submitBtn.textContent = 'Please wait...';
|
|
|
|
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 || 'Authentication failed');
|
|
}
|
|
|
|
// Store token
|
|
localStorage.setItem('authToken', data.token);
|
|
|
|
// Redirect to main app (replace history to prevent back button issues)
|
|
window.location.replace('/');
|
|
|
|
} catch (err) {
|
|
errorMessage.textContent = err.message;
|
|
errorMessage.classList.add('show');
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = isSetupMode ? 'Create Account' : 'Sign In';
|
|
}
|
|
});
|
|
|
|
// Check setup status on load
|
|
checkSetupRequired();
|
|
</script>
|
|
</body>
|
|
|
|
</html> |