<?php
// api/auth.php - unified auth endpoints wrapper for merged system
require_once __DIR__ . '/../_Core/bootstrap.php';
require_once __DIR__ . '/../_Core/Helpers.php';
require_once __DIR__ . '/../Controllers/AuthController.php';

$action = $_GET['action'] ?? $_POST['action'] ?? '';
$input = json_decode(file_get_contents('php://input'), true) ?: $_POST;

$ctrl = new Controllers\AuthController();

switch($action){
  case 'token_login':
    $res = $ctrl->tokenLogin($input); echo json_encode($res); break;
  case 'refresh':
    $res = $ctrl->refreshToken($input); echo json_encode($res); break;
  case 'list_devices':
    $res = $ctrl->listDevices(); echo json_encode($res); break;
  case 'revoke_device':
    $res = $ctrl->revokeDevice($input); echo json_encode($res); break;
  default:
    echo json_encode(['status'=>0,'error'=>'unknown_action']); break;
}
?>