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