<?php
// poll_admin_login_status.php
require_once 'auth/db.php';
header('Content-Type: application/json');

$pendingId = isset($_GET['pending_id']) ? intval($_GET['pending_id']) : 0;
if (!$pendingId) { echo json_encode(['error'=>'missing id']); exit; }

$stmt = $conn->prepare("SELECT status, approved_token FROM pending_admin_logins WHERE id = ?");
$stmt->bind_param("i",$pendingId);
$stmt->execute();
$stmt->bind_result($status, $token);
if ($stmt->fetch()) {
    echo json_encode(['status'=>$status, 'token'=>$token]);
} else {
    echo json_encode(['error'=>'not found']);
}
$stmt->close();
