diff --git a/src/Model/Behavior/SocialBehavior.php b/src/Model/Behavior/SocialBehavior.php index 36c0fb4c..2c0e982c 100644 --- a/src/Model/Behavior/SocialBehavior.php +++ b/src/Model/Behavior/SocialBehavior.php @@ -16,6 +16,7 @@ use Cake\Core\Configure; use Cake\Datasource\EntityInterface; use Cake\Event\EventDispatcherTrait; +use Cake\ORM\Query\SelectQuery; use Cake\Utility\Hash; use CakeDC\Users\Exception\AccountNotActiveException; use CakeDC\Users\Exception\MissingEmailException; @@ -138,7 +139,6 @@ protected function _createSocialUser($data, $options = []) $useEmail = $options['use_email'] ?? null; $validateEmail = (bool)($options['validate_email'] ?? null); $tokenExpiration = $options['token_expiration'] ?? null; - $existingUser = null; $email = $data['email'] ?? null; if ($useEmail && empty($email)) { throw new MissingEmailException(__d('cake_d_c/users', 'Email not present')); @@ -276,12 +276,11 @@ public function generateUniqueUsername($username) * Prepare a query to retrieve existing entity for social login * * @param \Cake\ORM\Query\SelectQuery $query The base query. - * @param array $options Find options with email key. + * @param string|null $email Find options with email key. * @return \Cake\ORM\Query\SelectQuery */ - public function findExistingForSocialLogin(\Cake\ORM\Query\SelectQuery $query, array $options) + public function findExistingForSocialLogin(SelectQuery $query, ?string $email = null): SelectQuery { - $email = $options['email'] ?? null; if (!$email) { return $query->where('1 != 1'); } diff --git a/tests/TestCase/Controller/Traits/Webauthn2FaTraitTest.php b/tests/TestCase/Controller/Traits/Webauthn2FaTraitTest.php index 6dfa19bf..2550c119 100644 --- a/tests/TestCase/Controller/Traits/Webauthn2FaTraitTest.php +++ b/tests/TestCase/Controller/Traits/Webauthn2FaTraitTest.php @@ -108,11 +108,10 @@ public function testWebauthn2faIsRegister() $this->Trait ->expects($this->exactly(2)) ->method('set') - ->willReturnCallback(fn ($name, $value) => - match ([$name, $value]) { - ['isRegister', true] => null, - ['username', 'user-2'] => null - }); + ->willReturnCallback(fn ($name, $value) => match ([$name, $value]) { + ['isRegister', true] => null, + ['username', 'user-2'] => null + }); $this->Trait->webauthn2fa(); $this->assertSame( $user, @@ -146,11 +145,10 @@ public function testWebauthn2faDontRequireRegister() $this->Trait ->expects($this->exactly(2)) ->method('set') - ->willReturnCallback(fn ($name, $value) => - match ([$name, $value]) { - ['isRegister', false] => null, - ['username', 'user-1'] => null - }); + ->willReturnCallback(fn ($name, $value) => match ([$name, $value]) { + ['isRegister', false] => null, + ['username', 'user-1'] => null + }); $this->Trait->webauthn2fa(); $this->assertSame( $user,