<?php
/**
 * Created by PhpStorm.
 * User: Joseg
 * Date: 4/6/2018
 * Time: 1:56 PM
 */

include '../comun/validarSesion.php';

if (isset($_REQUEST['token'])) {
    $Valido = new validator();
    if ($Valido->checkToken($_REQUEST['token'])){
        $creadoPor = $Valido->retornarIdToken($_REQUEST['token']);
        $condominioData = $Valido->retornarDatos($creadoPor);
        $condominio = $condominioData["condominio_id"];
        $usuarios = R::findAll( 'usuario', 'condominio_id = ?', [$condominio]);
        foreach ($usuarios as $valor) {
            unset($valor['clave']);
        }
        include '../comun/mensajeOk.php';
        print_r(json_encode($usuarios));
    }else{
        include '../comun/mensajeDatosInvalidos.php';
    }
}else{
    include '../comun/mensajeSesionInvalida.php';
}