Skip to content

Commit

Permalink
#1096: fixed findExistingForSocialLogin finder
Browse files Browse the repository at this point in the history
  • Loading branch information
arusinowski committed Sep 4, 2024
1 parent a4b213c commit d850b91
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Model/Behavior/SocialBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
namespace CakeDC\Users\Model\Behavior;

use Cake\Core\Configure;
use Cake\Database\Expression\QueryExpression;
use Cake\Datasource\EntityInterface;
use Cake\Event\EventDispatcherTrait;
use Cake\ORM\Query;
use Cake\Utility\Hash;
use CakeDC\Users\Exception\AccountNotActiveException;
use CakeDC\Users\Exception\MissingEmailException;
Expand Down Expand Up @@ -276,11 +278,15 @@ public function generateUniqueUsername($username)
* @param array $options Find options with email key.
* @return \Cake\ORM\Query
*/
public function findExistingForSocialLogin(\Cake\ORM\Query $query, array $options)
public function findExistingForSocialLogin(Query $query, array $options)
{
return $query->where([
$this->_table->aliasField('email') => $options['email'],
]);
if (!array_key_exists('email', $options)) {
throw new MissingEmailException(__d('cake_d_c/users', 'Email not present'));
}

return $query->where(fn(QueryExpression $expression) => $expression
->eq($this->_table->aliasField('email'), $options['email'])
);
}

/**
Expand Down

0 comments on commit d850b91

Please sign in to comment.