Skip to content

Commit

Permalink
#1096: simplified finder
Browse files Browse the repository at this point in the history
  • Loading branch information
arusinowski committed Sep 5, 2024
1 parent 916e158 commit 7c27286
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Model/Behavior/SocialBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
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;
Expand Down Expand Up @@ -140,7 +139,6 @@ protected function _createSocialUser($data, $options = [])
$useEmail = $options['use_email'] ?? null;
$validateEmail = $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'));
Expand Down Expand Up @@ -283,9 +281,13 @@ public function findExistingForSocialLogin(Query $query, array $options)
if (!array_key_exists('email', $options)) {
throw new MissingEmailException(__d('cake_d_c/users', 'Missing `email` option in options array'));
}
if (!$options['email']) {
return $query->where('1 != 1');
}

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

/**
Expand Down

0 comments on commit 7c27286

Please sign in to comment.