From 8c6d1bcf6d3db01bacb11dd893375c2e7162abf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20X=2E=20F=C3=BCrst?= Date: Sun, 1 Mar 2026 08:35:46 +0000 Subject: [PATCH] V 1.0.1: Auth erfolgreich --- app/login/actions.ts | 5 ----- debug-auth.js | 35 ----------------------------------- middleware.ts | 4 +--- 3 files changed, 1 insertion(+), 43 deletions(-) delete mode 100644 debug-auth.js diff --git a/app/login/actions.ts b/app/login/actions.ts index 80e8850..12030d9 100644 --- a/app/login/actions.ts +++ b/app/login/actions.ts @@ -8,16 +8,11 @@ export async function login(prevState: any, formData: FormData) { const username = formData.get('username') as string; const password = formData.get('password') as string; - console.log('Login attempt:', { username, passwordLength: password?.length }); - console.log('AUTH_USERS env:', process.env.AUTH_USERS); - if (!username || !password) { return { error: 'Bitte Benutzername und Passwort eingeben' }; } const isValid = verifyCredentials(username, password); - - console.log('Credentials valid:', isValid); if (!isValid) { return { error: 'Ungültige Anmeldedaten' }; diff --git a/debug-auth.js b/debug-auth.js deleted file mode 100644 index c714a77..0000000 --- a/debug-auth.js +++ /dev/null @@ -1,35 +0,0 @@ -const bcrypt = require('bcryptjs'); - -// Direkt aus .env kopiert -const AUTH_USERS = 'rxf:$2b$10$VdshbfnSFZIn59QJqDRiROi.ekU83ObiQBM.R3MVaSIcGQb5eYbEq'; - -console.log('=== AUTH DEBUG ===\n'); -console.log('AUTH_USERS:', AUTH_USERS); -console.log(''); - -const usersString = AUTH_USERS || ''; -const users = usersString - .split(',') - .map((userPair) => { - const [username, passwordHash] = userPair.trim().split(':'); - return { username: username?.trim(), passwordHash: passwordHash?.trim() }; - }) - .filter((user) => user.username && user.passwordHash); - -console.log('Parsed users:', JSON.stringify(users, null, 2)); -console.log(''); - -// Test credentials -const testUser = 'rxf'; -const testPassword = 'Fluorit'; - -const user = users.find(u => u.username === testUser); -console.log('Found user:', user); -console.log(''); - -if (user) { - console.log('Testing password:', testPassword); - console.log('Against hash:', user.passwordHash); - const result = bcrypt.compareSync(testPassword, user.passwordHash); - console.log('Result:', result); -} diff --git a/middleware.ts b/middleware.ts index 06f2505..68d704d 100644 --- a/middleware.ts +++ b/middleware.ts @@ -1,5 +1,4 @@ import { NextRequest, NextResponse } from 'next/server'; -import { cookies } from 'next/headers'; import { jwtVerify } from 'jose'; const SESSION_COOKIE_NAME = 'auth_session'; @@ -28,8 +27,7 @@ export async function middleware(request: NextRequest) { } // Check for session cookie - const cookieStore = await cookies(); - const sessionCookie = cookieStore.get(SESSION_COOKIE_NAME); + const sessionCookie = request.cookies.get(SESSION_COOKIE_NAME); if (!sessionCookie) { return NextResponse.redirect(new URL('/login', request.url));