From de56f0d7ef8346c02a27c2406553d6de3766483d Mon Sep 17 00:00:00 2001 From: Victor Ferreira Date: Sun, 12 Jul 2026 02:52:17 -0300 Subject: [PATCH 1/2] Sincroniza nome e e-mail do agente a cada login via Google --- Google/GoogleStrategy.php | 42 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/Google/GoogleStrategy.php b/Google/GoogleStrategy.php index 8217daf..05f551e 100644 --- a/Google/GoogleStrategy.php +++ b/Google/GoogleStrategy.php @@ -2,14 +2,15 @@ /** * Google strategy for Opauth * based on https://developers.google.com/accounts/docs/OAuth2 - * + * * More information on Opauth: http://opauth.org - * + * * @copyright Copyright © 2012 U-Zyn Chua (http://uzyn.com) * @link http://opauth.org * @package Opauth.GoogleStrategy * @license MIT License */ +use MapasCulturais\App; /** * Google strategy for Opauth * based on https://developers.google.com/accounts/docs/OAuth2 @@ -119,7 +120,42 @@ public function oauth2callback(){ $this->errorCallback($error); } } - + + /** + * Sincroniza nome e e-mail do agente a partir dos dados do Google. + * + * Assim como o GovBrStrategy, roda em todo login (não só na criação da conta), + * garantindo que agentes com nome vazio ou com o placeholder padrão sejam + * atualizados com os dados vindos do Google. + * + * @param \MapasCulturais\Entities\User $user + * @param array $response + * @return void + */ + public static function verifyUpdateData($user, $response) + { + $app = App::i(); + $info = $response['auth']['info']; + + $name = $info['name'] ?? trim(($info['first_name'] ?? '') . ' ' . ($info['last_name'] ?? '')); + + $app->disableAccessControl(); + + $profile = $user->profile; + + if ($name !== '' && ($profile->name == '' || $profile->name === 'Meu Nome')) { + $profile->name = $name; + } + + if (empty($profile->emailPrivado) && !empty($info['email'])) { + $profile->emailPrivado = $info['email']; + } + + $profile->save(true); + + $app->enableAccessControl(); + } + /** * Queries Google API for user info * From 40c6de9bb93c2cfc4136bec198fd49b1d32ecb1c Mon Sep 17 00:00:00 2001 From: Victor Ferreira Date: Sun, 12 Jul 2026 03:09:08 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Permite=20configurar=20o=20par=C3=A2metro?= =?UTF-8?q?=20prompt=20no=20login=20do=20Google?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Google/GoogleStrategy.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Google/GoogleStrategy.php b/Google/GoogleStrategy.php index 05f551e..77f5223 100644 --- a/Google/GoogleStrategy.php +++ b/Google/GoogleStrategy.php @@ -27,8 +27,8 @@ class GoogleStrategy extends OpauthStrategy{ /** * Optional config keys, without predefining any default values. */ - public $optionals = array('redirect_uri', 'scope', 'state', 'access_type', 'approval_prompt'); - + public $optionals = array('redirect_uri', 'scope', 'state', 'access_type', 'approval_prompt', 'prompt'); + /** * Optional config keys with respective default values, listed as associative arrays * eg. array('scope' => 'email');