diff --git a/src/Cacic/WSBundle/Controller/NeoController.php b/src/Cacic/WSBundle/Controller/NeoController.php index 775db97..39afb00 100644 --- a/src/Cacic/WSBundle/Controller/NeoController.php +++ b/src/Cacic/WSBundle/Controller/NeoController.php @@ -19,7 +19,8 @@ use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; use Cacic\CommonBundle\Entity\Computador; use Cacic\CommonBundle\Entity\LogAcesso; -use Cacic\CommonBundle\Entity\SoRepository; +use Cacic\CommonBundle\Entity\So; + class NeoController extends Controller { @@ -61,18 +62,25 @@ class NeoController extends Controller { // JSON Serialization //$usuario = $serializer->deserialize($data, 'Usuario', 'json'); $usuario = json_decode($data); - $logger->debug("JSON login received data".print_r($usuario, true)); + $logger->debug("JSON login received data".print_r($usuario, true)); //user e password $_SERVER['SERVER_ADDR'] = $this->getRequest()->getUri(); $auth = $this->forward('CacicCommonBundle:Security:login', array( - 'username' => $usuario->user, - 'password' => $usuario->password, + "username" => $usuario->user, + "password" => $usuario->password, )); + $logger->debug("JSON login received data".print_r($auth, true)); //dados .twig + $session = $request->getSession(); + //Gera chave criptografada + $chave = "123456"; + $chavecrip = md5($chave); + $auth->setContent(json_encode(array( - 'session' => $session->getId() + 'session' => $session->getId(), + 'chavecrip' => $chavecrip ))); return $auth; diff --git a/src/Cacic/WSBundle/Tests/Controller/NeoControllerTest.php b/src/Cacic/WSBundle/Tests/Controller/NeoControllerTest.php index 84c6334..889bdcd 100644 --- a/src/Cacic/WSBundle/Tests/Controller/NeoControllerTest.php +++ b/src/Cacic/WSBundle/Tests/Controller/NeoControllerTest.php @@ -12,7 +12,8 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Session; use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Encoder\JsonEncoder; -use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer; + + class NeoControllerTest extends WebTestCase { @@ -69,17 +70,22 @@ class NeoControllerTest extends WebTestCase "password": "123456" }' ); - $logger->debug("Dados JSON de login enviados \n".$this->client->getRequest()->getcontent()); + $logger->debug("Dados JSON de login enviados\n".$this->client->getRequest()->getcontent());//user e password $response = $this->client->getResponse(); + $logger->debug("Response:\n".print_r($response,true)); // arrays session e chavecrip $data = $response->getContent(); - $logger->debug("Response data: \n".print_r($data,true)); + $logger->debug("Response data:\n".print_r($data,true)); //session e chavecrip // JSON Serialization $json = json_decode($data, true); + $logger->debug("Response json: \n".print_r($json,true)); //session e chavecrip $session = $json['session']; + $chavecrip= $json['chavecrip']; $this->assertTrue(is_string($session)); + $this->assertTrue(is_string($chavecrip)); + } @@ -105,7 +111,7 @@ class NeoControllerTest extends WebTestCase $response = $this->client->getResponse(); $data = $response->getContent(); - $logger->debug("Response data: \n".print_r($data,true)); + // JSON Serialization $json = json_decode($data, true); $session = $json['session']; @@ -162,7 +168,7 @@ class NeoControllerTest extends WebTestCase $response = $this->client->getResponse(); $status = $response->getStatusCode(); - $logger->debug("Response status: $status"); + $logger->debug("Response status AAAAAAAAAAAAAAAAAAAAAAAAAAAA: $status"); $this->assertEquals($status, 200); -- libgit2 0.21.2