From 27d41c08477a10f8f2d4c77a56680e5c7faf7767 Mon Sep 17 00:00:00 2001 From: patrickzerhusen Date: Wed, 22 Apr 2026 14:34:03 +0200 Subject: [PATCH] simplified admin and mod authentification for new moderation page --- public/api/auth.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/public/api/auth.php b/public/api/auth.php index d38695f..3a0f71c 100644 --- a/public/api/auth.php +++ b/public/api/auth.php @@ -2,15 +2,10 @@ // ===================================================================== // Admin Authentication Helper // Provides simple Password-based Session Authentication for the -// Moderation Page. Uses ADMIN_PASSWORD from .env File. +// Moderation Page. Reads Password from .env File. // ToDo: Replace with full User Authentication in Phase 3-3. // ===================================================================== -// Reads Admin Password from Environment -function get_admin_password() { - return getenv('ADMIN_PASSWORD'); -} - // Checks if current Session is authenticated as Admin function is_admin() { return isset($_SESSION['is_admin']) && $_SESSION['is_admin'] === true; @@ -18,7 +13,7 @@ function is_admin() { // Authenticates with Password, returns true on Success function admin_login($password) { - $correct = get_admin_password(); + $correct = getenv('ADMIN_PASSWORD'); if ($correct && $password === $correct) { $_SESSION['is_admin'] = true; return true; @@ -30,12 +25,4 @@ function admin_login($password) { function admin_logout() { $_SESSION['is_admin'] = false; session_destroy(); -} - -// Redirects to Login if not authenticated -function require_admin() { - if (!is_admin()) { - header('Location: admin.php?page=login'); - exit; - } } \ No newline at end of file