From 85a7d05d44a96f17953ff39d0a3566181e67e20b Mon Sep 17 00:00:00 2001 From: eduardo.batista Date: Wed, 11 Oct 2017 19:17:42 -0300 Subject: [PATCH] [Refact] Preparando autenticação removendo cache do QRCode para atender emergência. --- MdWsSeiRest.php | 4 ++-- controlador_ws.php | 24 ++++-------------------- rn/MdWsSeiUsuarioRN.php | 63 +++++++++++++++++++++++++++++++++------------------------------ 3 files changed, 39 insertions(+), 52 deletions(-) diff --git a/MdWsSeiRest.php b/MdWsSeiRest.php index 5f3d55a..6da68d5 100644 --- a/MdWsSeiRest.php +++ b/MdWsSeiRest.php @@ -272,10 +272,10 @@ class MdWsSeiRest extends SeiIntegracao public function adicionarElementoMenu() { - $nomeArquivo = 'QRCODE_'.self::NOME_MODULO."_".SessaoSEI::getInstance()->getStrSiglaOrgaoSistema(); + $nomeArquivo = 'QRCODE_'.self::NOME_MODULO."_".SessaoSEI::getInstance()->getStrSiglaOrgaoUsuario(); $html = CacheSEI::getInstance()->getAtributo($nomeArquivo); - if(CacheSEI::getInstance()->getAtributo($nomeArquivo)){ + if($html){ return $html; } diff --git a/controlador_ws.php b/controlador_ws.php index a7f82e1..a5ca53d 100644 --- a/controlador_ws.php +++ b/controlador_ws.php @@ -75,24 +75,6 @@ $config = array( $app = new \Slim\App($config); -//Enable CORS -// $app->options('/{routes:.+}', function ($request, $response, $args) { -// return $response; -// }); - -// $app->add(function ($req, $res, $next) { -// $response = $next($req, $res); - -// //cabeçalhos encontrados na implementação do Mobile -// $strAllowHeaders = 'X-Requested-With, Content-Type, Accept, Origin, Authorization, Access-Control-Max-Age, If-Modified-Since' . -// 'token, User-Agent, Cookie, Content-Disposition, Content-Length, Transfer-Encoding, Accept-Encoding'; - -// return $response->withHeader('Access-Control-Allow-Origin', 'http://localhost:8100') //Especifico para o IONIC -// ->withHeader('Access-Control-Allow-Headers', $strAllowHeaders) -// ->withHeader('Access-Control-Allow-Credentials', 'true') -// ->withHeader('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE, OPTIONS, HEAD'); -// }); - /** * Grupo para a versao v1 de servicos REST */ @@ -108,9 +90,11 @@ $app->group('/api/v1',function(){ $usuarioDTO->setStrSigla($request->getParam('usuario')); $usuarioDTO->setStrSenha($request->getParam('senha')); $contextoDTO->setNumIdContexto($request->getParam('contexto')); - $contextoDTO->setNumIdOrgao($request->getParam('orgao')); + $orgaoDTO = new OrgaoDTO(); + $orgaoDTO->setNumIdOrgao($request->getParam('orgao')); + $orgaoDTO->setStrSigla($request->getParam('siglaorgao')); - return $response->withJSON($rn->apiAutenticar($usuarioDTO, $contextoDTO)); + return $response->withJSON($rn->apiAutenticar($usuarioDTO, $contextoDTO, $orgaoDTO)); }); /** * Grupo de controlador de Órgão diff --git a/rn/MdWsSeiUsuarioRN.php b/rn/MdWsSeiUsuarioRN.php index b378e67..cdc1886 100644 --- a/rn/MdWsSeiUsuarioRN.php +++ b/rn/MdWsSeiUsuarioRN.php @@ -121,10 +121,11 @@ class MdWsSeiUsuarioRN extends InfraRN { $usuarioDTO = new UsuarioDTO(); $usuarioDTO->setStrSigla($tokenData[0]); $usuarioDTO->setStrSenha($tokenData[1]); + $orgaoDTO = new OrgaoDTO(); + $orgaoDTO->setNumIdOrgao($tokenData[2]); $contextoDTO = new ContextoDTO(); - $contextoDTO->setNumIdOrgao($tokenData[2]); $contextoDTO->setNumIdContexto($tokenData[3]); - $result = $this->apiAutenticar($usuarioDTO, $contextoDTO); + $result = $this->apiAutenticar($usuarioDTO, $contextoDTO, $orgaoDTO); if(!$result['sucesso']){ return $result; } @@ -138,38 +139,40 @@ class MdWsSeiUsuarioRN extends InfraRN { /** * Metodo de autenticacao de usuarios usando SIP - * @param UsuarioDTO - * @param $sigla - * @param $senha - * @param $IdOrgao + * @param UsuarioDTO $usuarioDTO + * @param ContextoDTO $contextoDTO + * @param OrgaoDTO $orgaoDTO + * @return array */ - public function apiAutenticar(UsuarioDTO $usuarioDTO, ContextoDTO $contextoDTO){ + public function apiAutenticar(UsuarioDTO $usuarioDTO, ContextoDTO $contextoDTO, OrgaoDTO $orgaoDTO){ try{ $contexto = $contextoDTO->getNumIdContexto(); - $orgao = $contextoDTO->getNumIdOrgao(); - $siglaOrgao = null; - if(!$orgao){ - $orgaoRN = new OrgaoRN(); - $objOrgaoDTO = new OrgaoDTO(); - $objOrgaoDTO->setBolExclusaoLogica(false); - $objOrgaoDTO->retNumIdOrgao(); - $objOrgaoDTO->setStrSigla(ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaOrgaoSistema')); - /** - * @var $orgaoCarregdo OrgaoDTO - * Orgao da sessao do sistema - */ - $orgaoCarregdo = $orgaoRN->consultarRN1352($objOrgaoDTO); - $orgao = $orgaoCarregdo->getNumIdOrgao(); - $siglaOrgao = ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaOrgaoSistema'); - } + $orgao = $orgaoDTO->getNumIdOrgao(); + $siglaOrgao = $orgaoDTO->getStrSigla(); if(!$siglaOrgao){ - $orgaoRN = new OrgaoRN(); - $objOrgaoDTO = new OrgaoDTO(); - $objOrgaoDTO->setBolExclusaoLogica(false); - $objOrgaoDTO->retStrSigla(); - $objOrgaoDTO->setNumIdOrgao($orgao); - $objOrgaoDTO = $orgaoRN->consultarRN1352($objOrgaoDTO); - $siglaOrgao = $objOrgaoDTO->getStrSigla(); + if(!$orgao){ + $orgaoRN = new OrgaoRN(); + $objOrgaoDTO = new OrgaoDTO(); + $objOrgaoDTO->setBolExclusaoLogica(false); + $objOrgaoDTO->retNumIdOrgao(); + $objOrgaoDTO->setStrSigla(ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaOrgaoSistema')); + /** + * @var $orgaoCarregdo OrgaoDTO + * Orgao da sessao do sistema + */ + $orgaoCarregdo = $orgaoRN->consultarRN1352($objOrgaoDTO); + $orgao = $orgaoCarregdo->getNumIdOrgao(); + $siglaOrgao = ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaOrgaoSistema'); + } + if(!$siglaOrgao){ + $orgaoRN = new OrgaoRN(); + $objOrgaoDTO = new OrgaoDTO(); + $objOrgaoDTO->setBolExclusaoLogica(false); + $objOrgaoDTO->retStrSigla(); + $objOrgaoDTO->setNumIdOrgao($orgao); + $objOrgaoDTO = $orgaoRN->consultarRN1352($objOrgaoDTO); + $siglaOrgao = $objOrgaoDTO->getStrSigla(); + } } $objSipWs = $this->retornaServicoSip(); -- libgit2 0.21.2