Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
189e8b9
corrige erro na página Conta e privacidade
rafaelchavesfreitas Oct 17, 2024
c192a23
faz validação de obrigatoriedade de cpf
LimaSystem Dec 26, 2024
e93e821
corrige validação de cpf
rafaelchavesfreitas Dec 27, 2024
92e2ce5
Faz com que os cadastros criados apartir da nova versão do Mapas seja…
erleibiazzio Jan 3, 2025
38a3cc4
Cria componente para integração do gov-br / apenas front
Raul-vlb Mar 14, 2025
bade7df
Ajustes no componente de vinculação ao gov-br
Raul-vlb Mar 17, 2025
735e799
Criação e estilização do certificado do selo gov-br
Raul-vlb Mar 17, 2025
c747ae7
Exibe certificado do govbr na single do selo
Raul-vlb Mar 17, 2025
1417406
Ajustes na modal de vinculação do govbr
Raul-vlb Mar 18, 2025
0e429f3
Adição da modal de vinculação na tela 'conta e privacidade'
Raul-vlb Mar 18, 2025
9c67f87
Renova a data de verificação sempre que o usuário se autentica pelo G…
LimaSystem Mar 19, 2025
1a5d846
Renova a data de verificação sempre que o usuário se autentica pelo G…
LimaSystem Mar 19, 2025
05c6d12
W.I.P. Atualização do componente de cadastro para viculação com o govbr
Raul-vlb Mar 20, 2025
d424e9a
Inverte ordem de exibição do botão de vinculação do govbr
israelmelo Mar 25, 2025
f906312
Adiciona validações de erros relacionados aos cpfs duplicados e difer…
israelmelo Mar 25, 2025
9b8960a
Ajusta visualização do alert na página de Conta e Privacidade
israelmelo Mar 25, 2025
272c221
Corrige validação para cpf diferente
israelmelo Mar 25, 2025
557bcbe
Comenta partes do código que estão causando erro
israelmelo Mar 25, 2025
bd3d5e4
Retira return errors e corrige a renovação da data de verificação
israelmelo Mar 26, 2025
ffd6cae
Adiciona na single e na edição de agente individual, o botão de vincu…
israelmelo Mar 26, 2025
d7a0911
Ajusta redirecionamentos após erro ao se logar com o govbr
israelmelo Mar 27, 2025
b1e1eca
Adiciona na configuração e na mensagem de erro o e-mail de suporte
israelmelo Mar 28, 2025
8676e9b
Adiciona modal para oferecer vinculação com o govbr
israelmelo Mar 28, 2025
d275ca2
Ajustar alguns textos
leopiccionia Mar 28, 2025
7c3fc0a
Ajustar alguns textos
leopiccionia Mar 31, 2025
c68a347
Estilização do modal gov.br
leopiccionia Mar 31, 2025
a785ba8
Compartilhar templates entre login e vinculação gov.br
leopiccionia Mar 31, 2025
c734d20
Atualiza modal de vinculação
leopiccionia Mar 31, 2025
326e4da
Corrige regressões de estilização
leopiccionia Apr 1, 2025
5bcc960
Estilização de mensagens de erro
leopiccionia Apr 1, 2025
c6079d8
Corrige redirecionamento de erro quando está na single ou edit do agente
israelmelo Apr 1, 2025
5c2bbff
Corrige estilização das mensagens de erro do gov.br
leopiccionia Apr 1, 2025
2dd437a
Exibe o botão de vinculação gov.br no painel de Contas e Privacidade
leopiccionia Apr 1, 2025
a14d528
Refatora template part govbr-data.php para futuro refinamento
leopiccionia Apr 8, 2025
b29cab8
Refatora template part govbr-data.php para futuro refinamento
leopiccionia Apr 8, 2025
f3feef5
Refatora autenticação fora do govbr-data.php
leopiccionia Apr 8, 2025
f310081
Melhora estilização dos botões do gov.br
leopiccionia Apr 9, 2025
1f6fec4
Correção do botão gov.br na página de login
leopiccionia Apr 9, 2025
f995204
Caso os campos obrigatórios estejam vazios, agente terá o status de r…
Raul-vlb May 12, 2025
0af7fac
Melhoria no tratamento de erros ao criar um novo usuário e seu agente…
Raul-vlb May 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions GovBr/GovBrStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,29 @@ public static function verifyUpdateData($user, $response)
}
}
}
$user->profile->hasSeenSocialLinkingModal = true;
$user->profile->save(true);
$app->enableAccessControl();

$seal = $app->repo('Seal')->find($app->config['auth.config']['strategies']['govbr']['applySealId']);
$sealRelation = $app->repo('SealRelation')->findOneBy(['seal' => $seal, 'agent' => $user->profile->id]);

if ($sealRelation) {
$sealRelation->createTimestamp = new DateTime();
$app->em->persist($sealRelation);
$app->em->flush();
}

if($allAgents = $app->repo("Agent")->findBy(['userId' => $user->id, '_type' => 1])){

if(count($allAgents) == 1){
$_agent = $allAgents[0];
$_agent->setAsUserProfile();
}
}

setcookie('errorRedirectLocation', '', time() - 3600, '/');
unset($_COOKIE['errorRedirectLocation']);

self::getFile($user->profile, $userinfo->picture, $userinfo->access_token);
}
Expand All @@ -310,4 +323,45 @@ public static function mask($val, $mask) {
}
return $maskared;
}

public static function validateErrors($response, $user)
{
$app = App::i();
$errors = [];

if($agents_meta = self::getAgentsByDocumento($response)) {
if(count($agents_meta) > 1) {
$errors['cpf-duplicado'] = 'cpf-duplicado';
}
}

if($agents_meta = self::getUsersByEmail($response)) {
if(count($agents_meta) > 1) {
$errors['email-duplicado'] = 'email-duplicado';
}
}

$metadataFieldCpf = $app->config['auth.config']['metadataFieldCPF'];
if($agents_meta[0]->profile->{$metadataFieldCpf} != $user->profile->{$metadataFieldCpf}){
$errors['cpf-diferente'] = 'cpf-diferente';
}

return $errors;
}

public static function getAgentsByDocumento($response)
{
$app = App::i();
$metadataFieldCpf = $app->config['auth.config']['metadataFieldCPF'];
$cpf = self::mask($response['auth']['raw']['cpf'],'###.###.###-##');
return $cpf ? $app->repo('AgentMeta')->findBy(["key" => $metadataFieldCpf, "value" => $cpf]) : [];

}

public static function getUsersByEmail($response)
{
$app = App::i();
$email = $response['auth']['info']['email'];
return $email ? $app->repo('User')->findBy(['email' => $email]) : [];
}
}
111 changes: 105 additions & 6 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
include('GovBr/GovBrStrategy.php');

class Plugin extends \MapasCulturais\Plugin {

public function _init() {
$app = App::i();

$plugin = $this;

// register translation text domain
i::load_textdomain( 'multipleLocal', __DIR__ . "/translations" );

// Load JS & CSS
$app->hook('GET(<<auth|panel>>.<<*>>):before', function() use ($app) {
$app->hook('GET(<<*>>.<<*>>):before', function() use ($app) {
$app->view->enqueueStyle('app-v2', 'multipleLocal-v2', 'css/plugin-MultiplLocalAuth.css');
});

Expand All @@ -34,6 +35,51 @@ public function _init() {
$this->part('password/change-password');
});

$app->hook('template(panel.<<my-account|user-detail>>.user-mail):end ', function() use ($app, $plugin) {
/** @var \MapasCulturais\Theme $this */
$current_user = $app->user;
$can_seal = !$current_user->is('guest');

if ($app->config['auth.config']['strategies']['govbr']['visible'] && $can_seal) {
$has_govbr_seal = $plugin->hasGovBrSeal($current_user);
$this->part('govbr/govbr-data', [
'has_govbr_seal' => $has_govbr_seal,
'button_class' => 'login-govbr--panel',
'seal_class' => 'seal-govbr--panel',
]);
}
});

$app->hook('template(agent.single.single1-entity-info-mc-share-links):before', function() use ($app, $plugin) {
/** @var \MapasCulturais\Theme $this */
$current_user = $app->user;
$can_seal = !$current_user->is('guest') && $this->controller->requestedEntity->id == $current_user->profile->id;

if ($app->config['auth.config']['strategies']['govbr']['visible'] && $can_seal) {
$has_govbr_seal = $plugin->hasGovBrSeal($current_user);
$this->part('govbr/govbr-data', [
'has_govbr_seal' => $has_govbr_seal,
'button_class' => 'col-12',
'seal_class' => 'col-12',
]);
}
});

$app->hook('template(agent.edit.edit1-entity-info-site):after', function() use ($app, $plugin) {
/** @var \MapasCulturais\Theme $this */
$current_user = $app->user;
$can_seal = !$current_user->is('guest') && $this->controller->requestedEntity->id == $current_user->profile->id;

if ($app->config['auth.config']['strategies']['govbr']['visible'] && $can_seal) {
$has_govbr_seal = $plugin->hasGovBrSeal($current_user);
$this->part('govbr/govbr-data', [
'has_govbr_seal' => $has_govbr_seal,
'button_class' => 'col-12',
'seal_class' => 'col-12',
]);
}
});

$app->hook('entity(User).permissionsList,doctrine.emum(permission_action).values', function (&$permissions) {
$permissions[] = 'changePassword';
});
Expand All @@ -42,20 +88,73 @@ public function _init() {
$labels['changePassword'] = i::__('modificar senha');
});

$app->hook("controller(seal).render(sealrelation)", function(&$template, $seal) use ($app) {
$govbr_seal = $app->config['auth.config']['strategies']['govbr']['applySealId'];

if ($seal['relation']->seal->id == $govbr_seal) {
$template = "certificado-govbr";
}
});

// Carrega novos ícones 'iconfy' na estrutura default
$app->hook('component(mc-icon).iconset', function(&$iconset){
$iconset['cursor-click'] = "mynaui:click-solid";
});

$app->hook('template(<<*>>.main-header):after', function() use ($app) {
$is_admin = $app->user->is('admin');
$govbr_visible = $app->config['auth.config']['strategies']['govbr']['visible'];
$has_seen_modal = !$app->user->is('guest') ? $app->user->profile->hasSeenSocialLinkingModal : false;
$govbr_seal = $app->config['auth.config']['strategies']['govbr']['applySealId'];
$seal_relation = !$app->user->is('guest') && $govbr_seal ? $app->repo('SealRelation')->findOneBy(['seal' => $govbr_seal, 'agent' => $app->user->profile->id]) : false;

if ($govbr_visible && !$app->user->is('guest') && !$has_seen_modal && !$seal_relation && !$is_admin) {
$this->part('govbr/govbr-modal');
}
});

$app->hook('POST(site.desabilitar-modal)', function() use($app) {
$this->requireAuthentication();

$agent_id = $this->data['agentId'];
$agent = $app->repo('Agent')->find($agent_id);

if($agent) {
$agent->hasSeenSocialLinkingModal = true;
$agent->save(true);

$this->json(true);
}

$this->errorJson(false);
});

if (php_sapi_name() == "cli") {
if (!isset($_SERVER['HTTP_HOST'])) {
$_SERVER['HTTP_HOST'] = 'localhost';
}
}
}

public function register() {
$this->registerUserMetadata(Provider::$passMetaName, ['label' => i::__('Senha')]);
$this->registerUserMetadata(Provider::$recoverTokenMetadata, ['label' => i::__('Token para recuperação de senha')]);
$this->registerUserMetadata(Provider::$recoverTokenTimeMetadata, ['label' => i::__('Timestamp do token para recuperação de senha')]);
$this->registerUserMetadata(Provider::$accountIsActiveMetadata, ['label' => i::__('Conta ativa?')]);
$this->registerUserMetadata(Provider::$tokenVerifyAccountMetadata, ['label' => i::__('Token de verificação')]);
$this->registerUserMetadata(Provider::$loginAttempMetadata, ['label' => i::__('Número de tentativas de login')]);
$this->registerUserMetadata(Provider::$timeBlockedloginAttempMetadata, ['label' => i::__('Tempo de bloqueio por excesso de tentativas')]);
$this->registerUserMetadata(Provider::$timeBlockedloginAttempMetadata, ['label' => i::__('Tempo de bloqueio por excesso de tentativas')]);
$this->registerAgentMetadata('hasSeenSocialLinkingModal', [
'label' => i::__('Indica se o usuário já viu o modal de vinculação com redes sociais'),
'type' => 'boolean',
'default' => false
]);
}

public function hasGovBrSeal($user) {
$app = App::i();
$seal = $app->repo('Seal')->find($app->config['auth.config']['strategies']['govbr']['applySealId']);
$seal_relation = $app->repo('SealRelation')->findOneBy(['seal' => $seal, 'agent' => $user->profile->id]);
return !empty($seal_relation);
}
}
Loading