Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermednt committed Jun 29, 2016
2 parents b196cba + 5ff6caa commit 561183d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ security:
- { path: ^/connect/twitter$, role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
- { path: ^/connect/google$, role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
- { path: ^/login/facebook$, role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
- { path: ^/nfg/login$, role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
- { path: ^/nfg/(login|create), role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }

- { path: ^/monitor/health, role: IS_AUTHENTICATED_ANONYMOUSLY, ip: %allowed_monitors%, requires_channel: https }
- { path: ^/public/status, role: IS_AUTHENTICATED_ANONYMOUSLY, ip: %allowed_monitors%, requires_channel: https }

- { path: ^/nelmio/csp/report$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/(contact|privacy|about|help|register)$, role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
- { path: ^/(contact|privacy|about|help|register), role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
- { path: ^/person/checkEmailAvailable, role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }

- { path: ^/job, role: ROLE_SUPER_ADMIN, requires_channel: https }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
{% set form = lc_getFormFactory() %}
{% endif %}

<div class="row lc-main-title">
<div class="row lc-main-title hidden-xs">
<div class="col-12 text-center">
<h1>{% trans %}Citizen's Login{% endtrans %}</h1>
<h2 class="hidden-xs">{% trans %}One account. The entire Government.{% endtrans %}</h2>
<h2>{% trans %}One account. The entire Government.{% endtrans %}</h2>
</div>
</div>

Expand Down
27 changes: 23 additions & 4 deletions src/PROCERGS/LoginCidadao/CoreBundle/Controller/NfgController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PROCERGS\LoginCidadao\CoreBundle\Controller;

use LoginCidadao\CoreBundle\Model\PersonInterface;
use PROCERGS\LoginCidadao\CoreBundle\Entity\PersonMeuRS;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
Expand Down Expand Up @@ -59,9 +60,12 @@ protected function toNfg($url, $callback, $useSession = false)
*/
public function createBackAction(Request $request)
{
/** @var MeuRSHelper $meursHelper */
$meursHelper = $this->get('meurs.helper');

$result1 = $this->checkAccessToken();
$em = $this->getDoctrine()->getManager();
$personRepo = $em->getRepository('PROCERGSLoginCidadaoCoreBundle:Person');
$personRepo = $em->getRepository('LoginCidadaoCoreBundle:Person');
if ($personRepo->findOneBy(
array(
'cpf' => $result1['CodCpf'],
Expand Down Expand Up @@ -125,8 +129,8 @@ public function createBackAction(Request $request)
$nome = explode(' ', $result1['NomeConsumidor']);
$user->setFirstName(array_shift($nome));
$user->setSurname(implode(' ', $nome));

$em->persist($nfgProfile);
$user->setNfgProfile($nfgProfile);

$event = new GetResponseUserEvent($user, $request);
$dispatcher->dispatch(FOSUserEvents::REGISTRATION_INITIALIZE, $event);
Expand All @@ -143,6 +147,11 @@ public function createBackAction(Request $request)

$userManager->updateUser($user);

$personMeuRS = $meursHelper->getPersonMeuRS($user, true);
$personMeuRS->setNfgProfile($nfgProfile);
$em->persist($personMeuRS);
$em->flush($personMeuRS);

if (null === $response = $event->getResponse()) {
$url = $this->container->get('router')->generate('fos_user_registration_confirmed');
$response = new RedirectResponse($url);
Expand Down Expand Up @@ -195,6 +204,9 @@ public function loginAction()
*/
public function loginBacktAction(Request $request)
{
/** @var MeuRSHelper $meursHelper */
$meursHelper = $this->get('meurs.helper');

$cpf = $request->get('cpf');
$accessid = $request->get('accessid');
$prsec = $request->get('prsec');
Expand All @@ -214,13 +226,20 @@ public function loginBacktAction(Request $request)
}
$cpf = str_pad($cpf, 11, "0", STR_PAD_LEFT);
$em = $this->getDoctrine()->getManager();
$personRepo = $em->getRepository('PROCERGSLoginCidadaoCoreBundle:Person');
$personRepo = $em->getRepository('LoginCidadaoCoreBundle:Person');
$user = $personRepo->findOneBy(
array(
'cpf' => $cpf,
)
);
if (!$user || !$user->getNfgAccessToken()) {

if ($user instanceof PersonInterface) {
$personMeuRS = $meursHelper->getPersonMeuRS($user, true);
} else {
$personMeuRS = null;
}

if (!$user || !$personMeuRS->getNfgAccessToken()) {
throw new NfgException('nfg.user.notfound');
}
$response = $this->redirect($this->generateUrl('lc_home'));
Expand Down

0 comments on commit 561183d

Please sign in to comment.