346 lines
11 KiB
HTML
346 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Login - Audiobook Maker Pro</title>
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
|
|
<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=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
|
|
<style>
|
|
:root {
|
|
--primary-color: #4f46e5;
|
|
--primary-hover: #4338ca;
|
|
}
|
|
|
|
* { box-sizing: border-box; }
|
|
|
|
body {
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin: 0;
|
|
padding: 24px;
|
|
}
|
|
|
|
.login-container {
|
|
width: 100%;
|
|
max-width: 420px;
|
|
}
|
|
|
|
.login-card {
|
|
background: white;
|
|
border-radius: 20px;
|
|
padding: 48px 40px;
|
|
box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
|
|
animation: slideUp 0.4s ease;
|
|
}
|
|
|
|
@keyframes slideUp {
|
|
from { opacity: 0; transform: translateY(20px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
|
|
.login-header {
|
|
text-align: center;
|
|
margin-bottom: 36px;
|
|
}
|
|
|
|
.login-logo {
|
|
width: 64px;
|
|
height: 64px;
|
|
border-radius: 16px;
|
|
background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin: 0 auto 16px;
|
|
font-size: 1.75rem;
|
|
color: white;
|
|
}
|
|
|
|
.login-header h1 {
|
|
font-size: 1.5rem;
|
|
font-weight: 700;
|
|
color: #1e293b;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.login-header p {
|
|
color: #64748b;
|
|
font-size: 0.9rem;
|
|
margin: 0;
|
|
}
|
|
|
|
.form-label {
|
|
font-weight: 600;
|
|
color: #374151;
|
|
font-size: 0.85rem;
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.form-control {
|
|
padding: 12px 16px;
|
|
border: 2px solid #e2e8f0;
|
|
border-radius: 10px;
|
|
font-size: 0.95rem;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.form-control:focus {
|
|
border-color: var(--primary-color);
|
|
box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
|
|
}
|
|
|
|
.input-group-text {
|
|
background: #f8fafc;
|
|
border: 2px solid #e2e8f0;
|
|
border-right: none;
|
|
border-radius: 10px 0 0 10px;
|
|
color: #94a3b8;
|
|
}
|
|
|
|
.input-group .form-control {
|
|
border-left: none;
|
|
border-radius: 0 10px 10px 0;
|
|
}
|
|
|
|
.input-group:focus-within .input-group-text {
|
|
border-color: var(--primary-color);
|
|
}
|
|
|
|
.btn-login {
|
|
width: 100%;
|
|
padding: 12px;
|
|
background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
|
|
border: none;
|
|
border-radius: 10px;
|
|
color: white;
|
|
font-weight: 600;
|
|
font-size: 1rem;
|
|
transition: all 0.2s;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.btn-login:hover {
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 8px 25px rgba(79, 70, 229, 0.4);
|
|
color: white;
|
|
}
|
|
|
|
.btn-login:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.btn-login:disabled {
|
|
opacity: 0.7;
|
|
transform: none;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.login-error {
|
|
background: #fef2f2;
|
|
border: 1px solid #fecaca;
|
|
color: #dc2626;
|
|
border-radius: 10px;
|
|
padding: 12px 16px;
|
|
font-size: 0.85rem;
|
|
display: none;
|
|
align-items: center;
|
|
gap: 8px;
|
|
margin-bottom: 20px;
|
|
animation: shakeError 0.4s ease;
|
|
}
|
|
|
|
.login-error.visible {
|
|
display: flex;
|
|
}
|
|
|
|
@keyframes shakeError {
|
|
0%, 100% { transform: translateX(0); }
|
|
25% { transform: translateX(-8px); }
|
|
75% { transform: translateX(8px); }
|
|
}
|
|
|
|
.login-footer {
|
|
text-align: center;
|
|
margin-top: 24px;
|
|
color: #94a3b8;
|
|
font-size: 0.78rem;
|
|
}
|
|
|
|
.password-toggle {
|
|
position: absolute;
|
|
right: 12px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
background: none;
|
|
border: none;
|
|
color: #94a3b8;
|
|
cursor: pointer;
|
|
padding: 4px;
|
|
z-index: 5;
|
|
}
|
|
|
|
.password-toggle:hover {
|
|
color: #64748b;
|
|
}
|
|
|
|
.password-wrapper {
|
|
position: relative;
|
|
}
|
|
|
|
.password-wrapper .form-control {
|
|
padding-right: 44px;
|
|
}
|
|
|
|
.spinner-border-sm {
|
|
width: 1rem;
|
|
height: 1rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-container">
|
|
<div class="login-card">
|
|
<div class="login-header">
|
|
<div class="login-logo">
|
|
<i class="bi bi-soundwave"></i>
|
|
</div>
|
|
<h1>Audiobook Maker Pro</h1>
|
|
<p>Sign in to your account</p>
|
|
</div>
|
|
|
|
<div class="login-error" id="loginError">
|
|
<i class="bi bi-exclamation-triangle-fill"></i>
|
|
<span id="loginErrorText"></span>
|
|
</div>
|
|
|
|
<form id="loginForm" onsubmit="handleLogin(event)">
|
|
<div class="mb-3">
|
|
<label for="username" class="form-label">Username</label>
|
|
<div class="input-group">
|
|
<span class="input-group-text"><i class="bi bi-person"></i></span>
|
|
<input type="text" class="form-control" id="username"
|
|
placeholder="Enter your username" required autofocus
|
|
autocomplete="username">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
<label for="password" class="form-label">Password</label>
|
|
<div class="input-group">
|
|
<span class="input-group-text"><i class="bi bi-lock"></i></span>
|
|
<div class="password-wrapper" style="flex:1;">
|
|
<input type="password" class="form-control" id="password"
|
|
placeholder="Enter your password" required
|
|
autocomplete="current-password">
|
|
<button type="button" class="password-toggle" onclick="togglePassword()">
|
|
<i class="bi bi-eye" id="passwordToggleIcon"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-login" id="loginBtn">
|
|
<span id="loginBtnText">Sign In</span>
|
|
<div class="spinner-border spinner-border-sm" id="loginSpinner" style="display:none;" role="status"></div>
|
|
</button>
|
|
</form>
|
|
|
|
<div class="login-footer">
|
|
<i class="bi bi-shield-lock me-1"></i>
|
|
Audiobook Maker Pro v3.1
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function togglePassword() {
|
|
const input = document.getElementById('password');
|
|
const icon = document.getElementById('passwordToggleIcon');
|
|
|
|
if (input.type === 'password') {
|
|
input.type = 'text';
|
|
icon.classList.remove('bi-eye');
|
|
icon.classList.add('bi-eye-slash');
|
|
} else {
|
|
input.type = 'password';
|
|
icon.classList.remove('bi-eye-slash');
|
|
icon.classList.add('bi-eye');
|
|
}
|
|
}
|
|
|
|
async function handleLogin(event) {
|
|
event.preventDefault();
|
|
|
|
const username = document.getElementById('username').value.trim();
|
|
const password = document.getElementById('password').value;
|
|
const errorDiv = document.getElementById('loginError');
|
|
const errorText = document.getElementById('loginErrorText');
|
|
const loginBtn = document.getElementById('loginBtn');
|
|
const btnText = document.getElementById('loginBtnText');
|
|
const spinner = document.getElementById('loginSpinner');
|
|
|
|
// Hide previous error
|
|
errorDiv.classList.remove('visible');
|
|
|
|
// Show loading
|
|
loginBtn.disabled = true;
|
|
btnText.textContent = 'Signing in...';
|
|
spinner.style.display = 'inline-block';
|
|
|
|
try {
|
|
const response = await fetch('/api/auth/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ username, password })
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.error) {
|
|
errorText.textContent = data.error;
|
|
errorDiv.classList.add('visible');
|
|
loginBtn.disabled = false;
|
|
btnText.textContent = 'Sign In';
|
|
spinner.style.display = 'none';
|
|
|
|
// Shake the password field
|
|
document.getElementById('password').select();
|
|
return;
|
|
}
|
|
|
|
// Success — redirect
|
|
btnText.textContent = 'Redirecting...';
|
|
window.location.href = '/';
|
|
|
|
} catch (error) {
|
|
errorText.textContent = 'Network error. Please try again.';
|
|
errorDiv.classList.add('visible');
|
|
loginBtn.disabled = false;
|
|
btnText.textContent = 'Sign In';
|
|
spinner.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// Handle Enter key
|
|
document.addEventListener('keydown', function(e) {
|
|
if (e.key === 'Enter') {
|
|
document.getElementById('loginForm').requestSubmit();
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|