Ejemplo n.º 1
0
 public function prepare()
 {
     // i18n
     I18n::bind();
     $this->view()->set('lang', I18n::lang());
     $db = DatabaseConfig::getInstance();
     $db->setDev(NOVOSGA_DEV);
     $this->context = new Context($this, $db);
     $this->acessoService = new AcessoService();
     $this->add(new \Novosga\Slim\InstallMiddleware($this->context));
     $this->add(new \Novosga\Slim\AuthMiddleware($this->context));
 }
Ejemplo n.º 2
0
 public static function isNumeracaoServico()
 {
     if (App::isInstalled()) {
         $db = \Novosga\Config\DatabaseConfig::getInstance();
         $tipoNumeracao = \Novosga\Model\Configuracao::get($db->createEntityManager(), Senha::TIPO_NUMERACAO);
         if ($tipoNumeracao) {
             return $tipoNumeracao->getValor() == Senha::NUMERACAO_SERVICO;
         }
     }
     return false;
 }
Ejemplo n.º 3
0
<?php

/*
 * Novo SGA API
 */
require_once '../../bootstrap.php';
$app = new Slim\Slim(['debug' => false]);
$db = \Novosga\Config\DatabaseConfig::getInstance();
$em = $db->createEntityManager();
$server = new \Novosga\Api\OAuth2Server($em);
$api = new \Novosga\Api\ApiV1($em);
$app->error(function (Exception $e) use($app) {
    echo json_encode(['error' => $e->getMessage(), 'code' => $e->getCode()]);
});
$app->notFound(function () use($app) {
    echo json_encode(['error' => 'Not found', 'code' => '404']);
});
/*
 * Autentica o usuário retornando o token de acesso.
 * 
 * POST /token
 * {
 *   "grant_type": "password",
 *   "username": "******",
 *   "password": "******",
 *   "client_id": "..."
 * }
 * < 200
 * {
 *   "access_token": "6cdcf2e7a7bbeac1bd76dcbf33cb59b9b7341613",
 *   "expires_in": 3600,