<?php
require_once __DIR__.'/../../_bootstrap.php';require_once ROOT_PATH.'/includes/admin_functions.php';
if($_SERVER['REQUEST_METHOD']!=='POST')jsonResponse(['ok'=>false,'erro'=>'Método não permitido.'],405);
$d=requestJson();
try{$admin=afAdminLogin($pdo,(string)($d['email']??''),(string)($d['senha']??''),!empty($d['lembrar']));$token=$admin['_token']??'';unset($admin['_token']);jsonResponse(['ok'=>true,'token'=>$token,'admin'=>$admin]);}
catch(Throwable $e){jsonResponse(['ok'=>false,'erro'=>$e->getMessage()],401);}
