Skip to content

Commit

Permalink
Merge pull request #38 from PROCERGS/community
Browse files Browse the repository at this point in the history
Update community into rede livre version
  • Loading branch information
diegorojas committed Jul 13, 2016
2 parents 3ac1152 + c400eb0 commit de05292
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 34 deletions.
3 changes: 3 additions & 0 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,6 @@ liip_monitor:
services:
fos_user.doctrine_registry:
alias: doctrine

donato_path_well:
enabled: '%check_pathwell_topologies%'
3 changes: 3 additions & 0 deletions app/config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ parameters:

# Should sector_identifier_uri be revalidated on each auth request?
revalidate_sector_identifier_uri_on_auth: true

# Should passwords be checked for PathWell Topologies?
check_pathwell_topologies: true
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"nelmio/cors-bundle": "^1.4",
"nelmio/security-bundle": "^1.8",
"liip/monitor-bundle": "^2.2",
"guilhermednt/pathwell-bundle": "0.0.3"
"guilhermednt/pathwell-bundle": "^0.1"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
Expand Down
16 changes: 9 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 41 additions & 22 deletions src/LoginCidadao/CoreBundle/EventListener/LoggedInUserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace LoginCidadao\CoreBundle\EventListener;

use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Translation\TranslatorInterface;
Expand Down Expand Up @@ -38,18 +39,21 @@ class LoggedInUserListener
/** @var string */
private $defaultPasswordEncoder;

public function __construct(TokenStorageInterface $tokenStorage,
AuthorizationCheckerInterface $authChecker,
RouterInterface $router, Session $session,
TranslatorInterface $translator,
EntityManager $em, $defaultPasswordEncoder)
{
public function __construct(
TokenStorageInterface $tokenStorage,
AuthorizationCheckerInterface $authChecker,
RouterInterface $router,
Session $session,
TranslatorInterface $translator,
EntityManager $em,
$defaultPasswordEncoder
) {
$this->tokenStorage = $tokenStorage;
$this->authChecker = $authChecker;
$this->router = $router;
$this->session = $session;
$this->translator = $translator;
$this->em = $em;
$this->authChecker = $authChecker;
$this->router = $router;
$this->session = $session;
$this->translator = $translator;
$this->em = $em;

$this->defaultPasswordEncoder = $defaultPasswordEncoder;
}
Expand All @@ -63,7 +67,8 @@ public function onKernelRequest(GetResponseEvent $event)
$token = $this->tokenStorage->getToken();

if (is_null($token) || $token instanceof OAuthToken ||
$this->authChecker->isGranted('IS_AUTHENTICATED_REMEMBERED') === false) {
$this->authChecker->isGranted('IS_AUTHENTICATED_REMEMBERED') === false
) {
return;
}
if (!($token->getUser() instanceof PersonInterface)) {
Expand Down Expand Up @@ -98,19 +103,22 @@ private function handleTargetPath(GetResponseEvent $event)
} else {
$url = $this->router->generate('lc_dashboard');
}

return $this->redirectUrl($url);
}

protected function checkUnconfirmedEmail()
{
$token = $this->tokenStorage->getToken();
$user = $token->getUser();
$user = $token->getUser();
if (is_null($user->getEmailConfirmedAt())) {
$params = array('%url%' => $this->router->generate('lc_resend_confirmation_email'));
$title = $this->translator->trans('notification.unconfirmed.email.title');
$text = $this->translator->trans('notification.unconfirmed.email.shortText',
$params);
$alert = sprintf("<strong>%s</strong> %s", $title, $text);
$title = $this->translator->trans('notification.unconfirmed.email.title');
$text = $this->translator->trans(
'notification.unconfirmed.email.shortText',
$params
);
$alert = sprintf("<strong>%s</strong> %s", $title, $text);

$this->session->getFlashBag()->add('alert.unconfirmed.email', $alert);
}
Expand All @@ -119,7 +127,16 @@ protected function checkUnconfirmedEmail()
private function passwordEncoderMigration(GetResponseEvent $event)
{
$person = $this->tokenStorage->getToken()->getUser();
$route = $event->getRequest()->get('_route');
$route = $event->getRequest()->get('_route');

if ($route === 'tos_agree'
|| $route === 'tos_terms'
|| $event->getRequest()->attributes->get('_controller') == 'LoginCidadaoTOSBundle:Agreement'
|| $event->getRequest()->attributes->get('_controller') == 'LoginCidadaoTOSBundle:TermsOfService:showLatest'
|| $event->getRequestType() === HttpKernelInterface::SUB_REQUEST
) {
return;
}

if ($person->getEncoderName() === $this->defaultPasswordEncoder) {
return;
Expand All @@ -139,13 +156,14 @@ private function checkSessionInvalidation(GetResponseEvent $event)
return;
}

$person = $this->tokenStorage->getToken()->getUser();
$repo = $this->getInvalidateSessionRequestRepository();
$person = $this->tokenStorage->getToken()->getUser();
$repo = $this->getInvalidateSessionRequestRepository();
$request = $repo->findMostRecent($person);

$sessionCreation = $this->session->getMetadataBag()->getCreated();
if ($request === null ||
$sessionCreation > $request->getRequestedAt()->getTimestamp()) {
$sessionCreation > $request->getRequestedAt()->getTimestamp()
) {
return;
}

Expand All @@ -159,12 +177,13 @@ private function checkSessionInvalidation(GetResponseEvent $event)
private function getInvalidateSessionRequestRepository()
{
return $this->em
->getRepository('LoginCidadaoCoreBundle:InvalidateSessionRequest');
->getRepository('LoginCidadaoCoreBundle:InvalidateSessionRequest');
}

private function redirectRoute($name, $parameters = array())
{
$url = $this->router->generate($name, $parameters);

return $this->redirectUrl($url);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ registration.email.click: 'click here to confirm your email'
'Do you really want to unlink <strong class="social-network-name"></strong>?': 'Do you really want to unlink <strong class="social-network-name"></strong>?'
Yes: Yes
'Use accounts from other services': 'Use accounts from other services'
'Connect to the Nota Fiscal Gaúcha': 'Connect to the Nota Fiscal Gaúcha'
'By clicking on create account, you agree to our <a href="%linkTerms%">Privacy and Terms of Service</a>, including our Use of Cookies.': 'By clicking on create account, you agree to our <a href="%linkTerms%">Privacy and Terms of Service</a>, including our Use of Cookies.'
Change: Change
Personal Information: Personal Information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ registration.email.click: 'Confirmar Email'
'By clicking on create account, you agree to our <a href="%linkTerms%">Privacy and Terms of Service</a>, including our Use of Cookies.': 'Ao clicar em criar conta, você concorda com a <a href="%linkTerms%">Privacidade e Termos de uso</a> do serviço, incluindo nosso uso de cookies.'
'Do you really want to unlink <strong class="social-network-name"></strong>?': 'Tem certeza que deseja desvincular sua conta do <strong class="social-network-name"></strong>?'
Yes: Sim
'Connect to the Nota Fiscal Gaúcha': 'Conectar à Nota Fiscal Gaúcha'
'Continue Registration': 'Continuar Cadastro'
facebook.token.error: 'Aparentemente houve um erro na autenticação com o Facebook. Por favor, tente logar novamente!'
facebook.nousername: 'Conectado ao Facebook'
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@
</div>
</div>
{% endblock body %}

{% block javascripts %}
{{ parent() }}
<script>
$(document).ready(function(){
$('form').preventDoubleSubmission();
});
</script>
{% endblock %}

0 comments on commit de05292

Please sign in to comment.