Skip to content

Commit 7c27286

Browse files
committed
#1096: simplified finder
1 parent 916e158 commit 7c27286

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Model/Behavior/SocialBehavior.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace CakeDC\Users\Model\Behavior;
1515

1616
use Cake\Core\Configure;
17-
use Cake\Database\Expression\QueryExpression;
1817
use Cake\Datasource\EntityInterface;
1918
use Cake\Event\EventDispatcherTrait;
2019
use Cake\ORM\Query;
@@ -140,7 +139,6 @@ protected function _createSocialUser($data, $options = [])
140139
$useEmail = $options['use_email'] ?? null;
141140
$validateEmail = $options['validate_email'] ?? null;
142141
$tokenExpiration = $options['token_expiration'] ?? null;
143-
$existingUser = null;
144142
$email = $data['email'] ?? null;
145143
if ($useEmail && empty($email)) {
146144
throw new MissingEmailException(__d('cake_d_c/users', 'Email not present'));
@@ -283,9 +281,13 @@ public function findExistingForSocialLogin(Query $query, array $options)
283281
if (!array_key_exists('email', $options)) {
284282
throw new MissingEmailException(__d('cake_d_c/users', 'Missing `email` option in options array'));
285283
}
284+
if (!$options['email']) {
285+
return $query->where('1 != 1');
286+
}
286287

287-
return $query->where(fn(QueryExpression $expression) => $expression
288-
->eq($this->_table->aliasField('email'), $options['email']));
288+
return $query->where([
289+
$this->_table->aliasField('email') => $options['email'],
290+
]);
289291
}
290292

291293
/**

0 commit comments

Comments
 (0)