664 lines
23 KiB
HTML
664 lines
23 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Jellyfin</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Helvetica Neue', Arial, sans-serif;
|
|
background: #0d0d0d;
|
|
color: white;
|
|
height: 100vh;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.hero-background {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-image:
|
|
linear-gradient(to right, rgba(0,0,0,0.8) 30%, rgba(0,0,0,0.4) 60%, rgba(0,0,0,0.8) 100%),
|
|
linear-gradient(to bottom, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.6) 100%),
|
|
url('https://cdn.pixabay.com/photo/2021/12/12/20/00/popcorn-6865976_1280.jpg');
|
|
background-size: cover;
|
|
background-position: center;
|
|
animation: slowZoom 20s ease-in-out infinite alternate;
|
|
}
|
|
|
|
@keyframes slowZoom {
|
|
0% { transform: scale(1); }
|
|
100% { transform: scale(1.05); }
|
|
}
|
|
|
|
.content-overlay {
|
|
position: relative;
|
|
z-index: 10;
|
|
height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 0 4%;
|
|
}
|
|
|
|
.branding-section {
|
|
flex: 1;
|
|
max-width: 600px;
|
|
padding-right: 60px;
|
|
}
|
|
|
|
.logo-container {
|
|
margin-bottom: 40px;
|
|
}
|
|
|
|
.logo {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.logo-icon {
|
|
width: 50px;
|
|
height: 50px;
|
|
background: #e50914;
|
|
border-radius: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin-right: 15px;
|
|
}
|
|
|
|
.logo-icon svg {
|
|
width: 28px;
|
|
height: 28px;
|
|
fill: white;
|
|
}
|
|
|
|
.logo-text {
|
|
font-size: 36px;
|
|
font-weight: 700;
|
|
color: white;
|
|
letter-spacing: -1px;
|
|
}
|
|
|
|
.hero-title {
|
|
font-size: 48px;
|
|
font-weight: 700;
|
|
line-height: 1.1;
|
|
margin-bottom: 20px;
|
|
color: white;
|
|
}
|
|
|
|
.hero-subtitle {
|
|
font-size: 24px;
|
|
color: #cccccc;
|
|
margin-bottom: 30px;
|
|
font-weight: 400;
|
|
}
|
|
|
|
.feature-list {
|
|
list-style: none;
|
|
margin-bottom: 40px;
|
|
}
|
|
|
|
.feature-list li {
|
|
padding: 8px 0;
|
|
font-size: 16px;
|
|
color: #b3b3b3;
|
|
position: relative;
|
|
padding-left: 30px;
|
|
}
|
|
|
|
.feature-list li::before {
|
|
content: '✓';
|
|
position: absolute;
|
|
left: 0;
|
|
color: #00D4FF;
|
|
font-weight: bold;
|
|
font-size: 18px;
|
|
}
|
|
|
|
.login-section {
|
|
width: 450px;
|
|
background: rgba(0, 0, 0, 0.75);
|
|
border-radius: 4px;
|
|
padding: 60px 68px 40px;
|
|
}
|
|
|
|
.login-title {
|
|
font-size: 32px;
|
|
font-weight: 700;
|
|
margin-bottom: 28px;
|
|
color: white;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 16px;
|
|
position: relative;
|
|
}
|
|
|
|
.form-input {
|
|
width: 100%;
|
|
height: 50px;
|
|
background: #333333;
|
|
border: none;
|
|
border-radius: 4px;
|
|
padding: 16px 20px;
|
|
font-size: 16px;
|
|
color: white;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.form-input::placeholder {
|
|
color: #8c8c8c;
|
|
}
|
|
|
|
.form-input:focus {
|
|
outline: none;
|
|
background: #454545;
|
|
}
|
|
|
|
.form-input.error {
|
|
background: #e87c03;
|
|
}
|
|
|
|
.login-button {
|
|
width: 100%;
|
|
height: 48px;
|
|
background: #e50914;
|
|
border: none;
|
|
border-radius: 4px;
|
|
color: white;
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
cursor: pointer;
|
|
margin-top: 24px;
|
|
margin-bottom: 12px;
|
|
transition: background-color 0.2s ease;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.login-button:hover {
|
|
background: #f40612;
|
|
}
|
|
|
|
.login-button:active {
|
|
background: #d40812;
|
|
}
|
|
|
|
.login-button.loading {
|
|
background: #e50914;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.login-button.loading::after {
|
|
content: '';
|
|
position: absolute;
|
|
width: 20px;
|
|
height: 20px;
|
|
margin: auto;
|
|
border: 2px solid transparent;
|
|
border-top-color: white;
|
|
border-radius: 50%;
|
|
animation: spin 1s ease infinite;
|
|
top: 0;
|
|
left: 0;
|
|
bottom: 0;
|
|
right: 0;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
|
|
.error-message {
|
|
background: #e87c03;
|
|
color: white;
|
|
padding: 10px 16px;
|
|
border-radius: 4px;
|
|
margin-bottom: 16px;
|
|
font-size: 14px;
|
|
opacity: 0;
|
|
transform: translateY(-10px);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.error-message.show {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.success-message {
|
|
background: rgba(46, 125, 50, 0.1);
|
|
border: 1px solid #4caf50;
|
|
color: #81c784;
|
|
padding: 16px;
|
|
border-radius: 4px;
|
|
margin-bottom: 16px;
|
|
font-size: 14px;
|
|
opacity: 0;
|
|
transform: translateY(-10px);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.success-message.show {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.help-text {
|
|
color: #737373;
|
|
font-size: 13px;
|
|
margin-top: 16px;
|
|
}
|
|
|
|
.help-text a {
|
|
color: white;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.help-text a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
|
|
|
|
.floating-particles {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
pointer-events: none;
|
|
z-index: 1;
|
|
}
|
|
|
|
.particle {
|
|
position: absolute;
|
|
width: 2px;
|
|
height: 2px;
|
|
background: rgba(255, 255, 255, 0.3);
|
|
border-radius: 50%;
|
|
animation: float 8s infinite linear;
|
|
}
|
|
|
|
@keyframes float {
|
|
0% {
|
|
transform: translateY(100vh) rotate(0deg);
|
|
opacity: 0;
|
|
}
|
|
10% {
|
|
opacity: 1;
|
|
}
|
|
90% {
|
|
opacity: 1;
|
|
}
|
|
100% {
|
|
transform: translateY(-10vh) rotate(360deg);
|
|
opacity: 0;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 950px) {
|
|
.content-overlay {
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
padding: 20px;
|
|
}
|
|
|
|
.branding-section {
|
|
display: none;
|
|
}
|
|
|
|
.login-section {
|
|
width: 100%;
|
|
max-width: 450px;
|
|
padding: 48px 32px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.login-section {
|
|
padding: 40px 24px;
|
|
}
|
|
|
|
.hero-title {
|
|
font-size: 36px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="hero-background"></div>
|
|
|
|
<div class="floating-particles" id="particles"></div>
|
|
|
|
|
|
|
|
<div class="content-overlay">
|
|
<div class="branding-section">
|
|
<div class="logo-container">
|
|
<div class="logo">
|
|
<div class="logo-icon">
|
|
<svg viewBox="0 0 24 24">
|
|
<path d="M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z"/>
|
|
</svg>
|
|
</div>
|
|
<div class="logo-text">Jellyfin</div>
|
|
</div>
|
|
</div>
|
|
|
|
<h1 class="hero-title">Your personal media universe</h1>
|
|
<p class="hero-subtitle" id="serverStatusText">Server is offline - will start automatically after login</p>
|
|
</div>
|
|
|
|
<div class="login-section">
|
|
<h2 class="login-title">Sign In</h2>
|
|
|
|
<form id="loginForm">
|
|
<div class="error-message" id="errorMessage"></div>
|
|
<div class="success-message" id="successMessage"></div>
|
|
|
|
<div class="form-group">
|
|
<input type="text" class="form-input" id="username" placeholder="Username" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<input type="password" class="form-input" id="password" placeholder="Password" required>
|
|
</div>
|
|
|
|
<button type="submit" class="login-button" id="loginButton">
|
|
<span id="buttonText">Sign In</span>
|
|
</button>
|
|
</form>
|
|
|
|
<div class="help-text">
|
|
Secure access to your personal media server
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Create floating particles
|
|
function createParticles() {
|
|
const container = document.getElementById('particles');
|
|
const particleCount = 30;
|
|
|
|
for (let i = 0; i < particleCount; i++) {
|
|
const particle = document.createElement('div');
|
|
particle.className = 'particle';
|
|
particle.style.left = Math.random() * 100 + '%';
|
|
particle.style.animationDelay = Math.random() * 8 + 's';
|
|
particle.style.animationDuration = (Math.random() * 4 + 6) + 's';
|
|
container.appendChild(particle);
|
|
}
|
|
}
|
|
|
|
// Server status management
|
|
let serverStatus = 'offline';
|
|
const serverStatusText = document.getElementById('serverStatusText');
|
|
|
|
function updateServerStatus(status) {
|
|
serverStatus = status;
|
|
|
|
switch(status) {
|
|
case 'offline':
|
|
serverStatusText.textContent = 'Server is offline - will start automatically after login';
|
|
break;
|
|
case 'starting':
|
|
serverStatusText.textContent = 'Starting media server - please wait...';
|
|
break;
|
|
case 'running':
|
|
serverStatusText.textContent = 'Server is running - redirecting to your media library';
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Generate device ID based on browser fingerprint
|
|
function generateDeviceId() {
|
|
const userAgent = navigator.userAgent;
|
|
const timestamp = Date.now().toString();
|
|
const combined = userAgent + '|' + timestamp;
|
|
// Base64 encode the combined string
|
|
return btoa(combined);
|
|
}
|
|
|
|
// Get browser/device information
|
|
function getBrowserInfo() {
|
|
const userAgent = navigator.userAgent;
|
|
let browser = 'Unknown';
|
|
let device = 'Unknown';
|
|
|
|
if (userAgent.includes('Chrome')) {
|
|
browser = 'Jellyfin Web';
|
|
device = 'Chrome';
|
|
} else if (userAgent.includes('Firefox')) {
|
|
browser = 'Jellyfin Web';
|
|
device = 'Firefox';
|
|
} else if (userAgent.includes('Safari')) {
|
|
browser = 'Jellyfin Web';
|
|
device = 'Safari';
|
|
} else if (userAgent.includes('Edge')) {
|
|
browser = 'Jellyfin Web';
|
|
device = 'Edge';
|
|
}
|
|
|
|
return { browser, device };
|
|
}
|
|
|
|
// Form handling
|
|
document.getElementById('loginForm').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
const loginButton = document.getElementById('loginButton');
|
|
const buttonText = document.getElementById('buttonText');
|
|
const errorMessage = document.getElementById('errorMessage');
|
|
const successMessage = document.getElementById('successMessage');
|
|
const usernameInput = document.getElementById('username');
|
|
const passwordInput = document.getElementById('password');
|
|
|
|
// Clear previous states
|
|
errorMessage.classList.remove('show');
|
|
successMessage.classList.remove('show');
|
|
usernameInput.classList.remove('error');
|
|
passwordInput.classList.remove('error');
|
|
|
|
// Validate inputs
|
|
if (!username || !password) {
|
|
errorMessage.textContent = 'Please enter both username and password.';
|
|
errorMessage.classList.add('show');
|
|
if (!username) usernameInput.classList.add('error');
|
|
if (!password) passwordInput.classList.add('error');
|
|
return;
|
|
}
|
|
|
|
// Show loading state
|
|
loginButton.classList.add('loading');
|
|
buttonText.style.opacity = '0';
|
|
|
|
try {
|
|
// Generate authorization header
|
|
const { browser, device } = getBrowserInfo();
|
|
const deviceId = generateDeviceId();
|
|
const version = "10.10.5";
|
|
const authHeader = `MediaBrowser Client="${browser}", Device="${device}", DeviceId="${deviceId}", Version="${version}"`;
|
|
|
|
// Authenticate with backend
|
|
const response = await fetch('/Users/AuthenticateByName', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': authHeader
|
|
},
|
|
body: JSON.stringify({
|
|
Username: username,
|
|
Pw: password
|
|
})
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Authentication failed. Please check your credentials.');
|
|
}
|
|
|
|
const authData = await response.json();
|
|
|
|
// Store credentials in localStorage in Jellyfin Web Client format
|
|
// Use the same device info that was sent in the request
|
|
const jellyfinCredentials = {
|
|
"Servers": [{
|
|
"ManualAddress": "http://localhost:8096",
|
|
"manualAddressOnly": true,
|
|
"AccessToken": authData.AccessToken,
|
|
"UserId": authData.User.Id,
|
|
"DeviceId": deviceId,
|
|
"Client": browser,
|
|
"Device": device,
|
|
"Version": version
|
|
}]
|
|
};
|
|
|
|
localStorage.setItem('jellyfin_credentials', JSON.stringify(jellyfinCredentials));
|
|
|
|
// Show success
|
|
successMessage.textContent = 'Authentication successful! Initializing media server...';
|
|
successMessage.classList.add('show');
|
|
|
|
// Update server status
|
|
updateServerStatus('starting');
|
|
|
|
// Wait a moment then check if server is ready
|
|
setTimeout(() => {
|
|
updateServerStatus('running');
|
|
successMessage.textContent = 'Welcome to your media library! Redirecting...';
|
|
|
|
// Redirect to root which should now proxy to Jellyfin
|
|
setTimeout(() => {
|
|
window.location.href = '/';
|
|
}, 1500);
|
|
}, 2000);
|
|
|
|
} catch (error) {
|
|
// Show error
|
|
errorMessage.textContent = error.message || 'Authentication failed. Please check your credentials.';
|
|
errorMessage.classList.add('show');
|
|
usernameInput.classList.add('error');
|
|
passwordInput.classList.add('error');
|
|
|
|
// Reset button
|
|
loginButton.classList.remove('loading');
|
|
buttonText.style.opacity = '1';
|
|
}
|
|
});
|
|
|
|
// Check for existing authentication
|
|
async function checkExistingAuth() {
|
|
const credentials = localStorage.getItem('jellyfin_credentials');
|
|
if (credentials) {
|
|
try {
|
|
const parsedCreds = JSON.parse(credentials);
|
|
if (parsedCreds.Servers && parsedCreds.Servers.length > 0) {
|
|
const server = parsedCreds.Servers[0];
|
|
if (server.AccessToken && server.DeviceId) {
|
|
// Show that we're checking authentication
|
|
successMessage.textContent = 'Found existing credentials, validating...';
|
|
successMessage.classList.add('show');
|
|
updateServerStatus('starting');
|
|
|
|
// Use stored device information
|
|
const authHeaderWithToken = `MediaBrowser Client="${server.Client || 'Jellyfin Web'}", Device="${server.Device || 'Chrome'}", DeviceId="${server.DeviceId}", Version="${server.Version || '10.10.5'}", Token="${server.AccessToken}"`;
|
|
|
|
// Test if the token is still valid by making any authenticated request
|
|
// This will trigger server startup if needed and validate the token
|
|
const testResponse = await fetch('/', {
|
|
headers: {
|
|
'Authorization': authHeaderWithToken
|
|
}
|
|
});
|
|
|
|
if (testResponse.ok || testResponse.status === 503) {
|
|
// Token is valid (or server is starting up), wait for full startup
|
|
successMessage.textContent = 'Authentication successful! Starting media server...';
|
|
updateServerStatus('starting');
|
|
|
|
// Wait for server to fully start up and then redirect
|
|
setTimeout(async () => {
|
|
// Check if we can access the main page now
|
|
try {
|
|
const finalCheck = await fetch('/', {
|
|
headers: {
|
|
'Authorization': authHeaderWithToken
|
|
}
|
|
});
|
|
|
|
if (finalCheck.ok) {
|
|
successMessage.textContent = 'Media server ready! Redirecting...';
|
|
updateServerStatus('running');
|
|
setTimeout(() => {
|
|
window.location.href = '/';
|
|
}, 1000);
|
|
} else {
|
|
// Server might still be starting, try one more time
|
|
setTimeout(() => {
|
|
window.location.href = '/';
|
|
}, 2000);
|
|
}
|
|
} catch (e) {
|
|
// Network error, just try to redirect anyway
|
|
setTimeout(() => {
|
|
window.location.href = '/';
|
|
}, 1000);
|
|
}
|
|
}, 3000);
|
|
} else if (testResponse.status === 401) {
|
|
// Token is invalid, clear it and show login form
|
|
console.log('Token invalid, clearing credentials');
|
|
localStorage.removeItem('jellyfin_credentials');
|
|
successMessage.classList.remove('show');
|
|
updateServerStatus('offline');
|
|
} else {
|
|
// Other error, maybe server startup failed, but keep credentials for now
|
|
console.log('Server error, status:', testResponse.status);
|
|
successMessage.textContent = 'Server error occurred. Please try again.';
|
|
successMessage.classList.remove('show');
|
|
updateServerStatus('offline');
|
|
}
|
|
}
|
|
}
|
|
} catch (e) {
|
|
// Invalid credentials, clear them
|
|
console.log('Error parsing credentials:', e);
|
|
localStorage.removeItem('jellyfin_credentials');
|
|
successMessage.classList.remove('show');
|
|
updateServerStatus('offline');
|
|
}
|
|
}
|
|
}
|
|
|
|
// Initialize
|
|
createParticles();
|
|
updateServerStatus('offline');
|
|
|
|
// Check if user is already authenticated
|
|
checkExistingAuth();
|
|
|
|
// Add input focus effects
|
|
document.querySelectorAll('.form-input').forEach(input => {
|
|
input.addEventListener('focus', function() {
|
|
this.classList.remove('error');
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |