Skip to content

Commit

Permalink
Merge pull request #402 from PROCERGS/dev
Browse files Browse the repository at this point in the history
Fixes #398 and #399
  • Loading branch information
guilhermednt authored Jun 29, 2016
2 parents 561183d + 289ba48 commit 5cb29e8
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ form.mobile: Celular
form.mobile.example: (51) 99999-9999
resseting.forgot_password: 'Esqueceu sua senha?'
resetting.request.invalid_username: 'O CPF, nome de usuário ou email "%username%" não está cadastrado.'
resetting.request.username: 'Email ou CPF:'
resetting.request.username: 'Email ou CPF'
resetting.request.submit: 'Recuperar senha'
resetting.check_email: 'Foi enviado um email para %email%. Para recuperar a sua senha, clique no link da mensagem.'
resetting.email.subject: 'Redefinir senha'
resetting.email.message: 'Alguém solicitou recentemente para redefinir sua senha do Login Cidadão.'
resetting.email.message: 'Alguém solicitou recentemente para redefinir sua senha do Login Cidadão. Se você não fez essa solicitação, apenas ignore essa mensagem.'
resetting.reset.submit: 'Alterar senha'
resetting.password_already_requested: 'Este usuário já solicitou uma senha nas últimas 24 horas.'
change_password.submit: 'Alterar senha'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
{% block body_text %}
{% autoescape false %}
{{ 'resetting.email.message'|trans({'%username%': user.shortDisplayName, '%confirmationUrl%': confirmationUrl}) }}

{{ confirmationUrl }}
{% endautoescape %}
{% endblock %}


{% block body_html %}
{% autoescape false %}
{{ include("LoginCidadaoCoreBundle::common.email.html.twig", {'subject' : 'registration.email.subject'|trans({'%username%': user.shortDisplayName}), 'msg' : 'resetting.email.message'|trans, 'url' : confirmationUrl } ) }}
{{ include("LoginCidadaoCoreBundle::common.email.html.twig", {'subject' : 'resetting.email.subject'|trans({'%username%': user.shortDisplayName}), 'msg' : 'resetting.email.message'|trans, 'url' : confirmationUrl } ) }}
{% endautoescape %}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/**
* This file is part of the login-cidadao project or it's bundles.
*
* (c) Guilherme Donato <guilhermednt on github>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace PROCERGS\LoginCidadao\CoreBundle\EventListener;

use JMS\Serializer\EventDispatcher\EventSubscriberInterface;
use JMS\Serializer\EventDispatcher\ObjectEvent;
use JMS\Serializer\Serializer;
use LoginCidadao\OAuthBundle\Model\AccessTokenManager;
use LoginCidadao\CoreBundle\Model\PersonInterface;
use PROCERGS\LoginCidadao\CoreBundle\Entity\PersonMeuRS;
use PROCERGS\LoginCidadao\CoreBundle\Helper\MeuRSHelper;

class PersonSerializeEventListenner implements EventSubscriberInterface
{
/** @var MeuRSHelper */
protected $meuRSHelper;

/** @var Serializer */
protected $serializer;

/** @var string */
protected $pairwiseSubjectIdSalt;

/**
* PersonSerializeEventListenner constructor.
* @param MeuRSHelper $meuRSHelper
* @param Serializer $serializer
*/
public function __construct(MeuRSHelper $meuRSHelper, Serializer $serializer)
{
$this->meuRSHelper = $meuRSHelper;
$this->serializer = $serializer;
}

public static function getSubscribedEvents()
{
return array(
array(
'event' => 'serializer.post_serialize',
'method' => 'onPostSerialize',
'class' => 'LoginCidadao\CoreBundle\Model\PersonInterface',
),
);
}

public function onPostSerialize(ObjectEvent $event)
{
if (!($event->getObject() instanceof PersonInterface)) {
return;
}
$this->setVoterRegistration($event);
}

private function setVoterRegistration(ObjectEvent $event)
{
$personMeuRS = $this->meuRSHelper->getPersonMeuRS($event->getObject(), false);

if (!($personMeuRS instanceof PersonMeuRS)) {
return;
}

$groups = $event->getContext()->attributes->get('groups')->get();
if (array_search('voter_registration', $groups) !== false) {
$event->getVisitor()->addData('voter_registration', $personMeuRS->getVoterRegistration());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,11 @@ services:
- [setMeuRSHelper, [@meurs.helper] ]
tags:
- { name: form.type, alias: person_doc_form_type }

rs.person.serialize.listenner:
class: PROCERGS\LoginCidadao\CoreBundle\EventListener\PersonSerializeEventListenner
arguments:
- "@meurs.helper"
- "@jms_serializer"
tags:
- { name: jms_serializer.event_listener, event: serializer.post_serialize, method: onPostSerialize }

0 comments on commit 5cb29e8

Please sign in to comment.