Initial commit of YouTube Downloader application, including core functionality for downloading videos, user authentication, and Docker support. Added configuration files, environment setup, and basic UI components using Astro.js and Tailwind CSS.

This commit is contained in:
Peter Meier
2025-12-22 10:59:01 +01:00
parent 79d8a95391
commit 486639aaea
31 changed files with 13078 additions and 132 deletions

57
src/pages/api/login.ts Normal file
View File

@@ -0,0 +1,57 @@
import type { APIRoute } from 'astro';
import { createSessionCookie, isLoginEnabled } from '../../lib/session';
export const POST: APIRoute = async ({ request }) => {
// Wenn Login deaktiviert ist, weiterleiten
if (!isLoginEnabled()) {
return new Response(null, {
status: 302,
headers: {
'Location': new URL('/download', request.url).toString(),
},
});
}
const formData = await request.formData();
const username = formData.get('username')?.toString();
const password = formData.get('password')?.toString();
// Credentials aus Environment-Variablen
const envUsername = import.meta.env.LOGIN_USERNAME;
const envPassword = import.meta.env.LOGIN_PASSWORD;
// Prüfe ob Credentials konfiguriert sind
if (!envUsername || !envPassword) {
console.error('LOGIN_USERNAME oder LOGIN_PASSWORD nicht in Environment-Variablen gesetzt!');
return new Response(null, {
status: 302,
headers: {
'Location': new URL('/', request.url).toString(),
},
});
}
// Authentifizierung gegen Environment-Variablen
if (username === envUsername && password === envPassword) {
const session = {
username,
loggedIn: true,
};
return new Response(null, {
status: 302,
headers: {
'Location': new URL('/download', request.url).toString(),
'Set-Cookie': createSessionCookie(session),
},
});
}
// Falsche Credentials
return new Response(null, {
status: 302,
headers: {
'Location': new URL('/', request.url).toString(),
},
});
};