Commit 89f576f65467849951e67050399d37391e836c2f

Authored by eduardo.batista
1 parent 209f783a
Exists in master and in 1 other branch desenv

[FEAT] Adicionando os perfis do usuário no método autenticar.

Showing 1 changed file with 37 additions and 0 deletions   Show diff stats
rn/MdWsSeiUsuarioRN.php
... ... @@ -166,11 +166,18 @@ class MdWsSeiUsuarioRN extends InfraRN {
166 166 $unidadeDTOConsulta = new UnidadeDTO();
167 167 $unidadeDTOConsulta->setNumMaxRegistrosRetorno(99999);//pedido da MBA
168 168 $arrUnidades = $unidadeRN->pesquisarUnidade($unidadeDTOConsulta);
  169 + $arrPerfis = array();
  170 + $retPerfis = $this->listarPerfisUsuario($ret->id_sistema, $ret->id_usuario);
  171 + if($retPerfis && $retPerfis['data']){
  172 + $arrPerfis = $retPerfis['data'];
  173 + }
  174 +
169 175  
170 176 return MdWsSeiRest::formataRetornoSucessoREST(
171 177 null,
172 178 array(
173 179 'loginData'=> $ret,
  180 + 'perfis' => $arrPerfis,
174 181 'unidades' => $arrUnidades['data'],
175 182 'token' => $token
176 183 )
... ... @@ -182,6 +189,36 @@ class MdWsSeiUsuarioRN extends InfraRN {
182 189 }
183 190  
184 191 /**
  192 + * Método que retorna os perfis do usuário
  193 + * @param $idSistema
  194 + * @param $idUsuario
  195 + * @return array
  196 + */
  197 + private function listarPerfisUsuario($idSistema, $idUsuario){
  198 + try{
  199 + $arrPerfis = array();
  200 + $objSipWs = $this->retornaServicoSip();
  201 + $ret = $objSipWs->carregarPerfis(
  202 + $idSistema,
  203 + $idUsuario
  204 + );
  205 + $arrPerfis = array();
  206 + foreach ($ret as $perfil) {
  207 + $arrPerfis[] = array(
  208 + 'idPerfil' => $perfil[0],
  209 + 'nome' => $perfil[1],
  210 + 'stAtivo' => $perfil[3]
  211 + );
  212 + }
  213 +
  214 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrPerfis);
  215 +
  216 + }catch (Exception $e){
  217 + return MdWsSeiRest::formataRetornoErroREST($e);
  218 + }
  219 + }
  220 +
  221 + /**
185 222 * Retorna a lista de usuarios por unidade
186 223 * @param UsuarioDTO
187 224 * @param $idUsuario
... ...