|
16 | 16 | use Cake\Core\Configure; |
17 | 17 | use Cake\Datasource\EntityInterface; |
18 | 18 | use Cake\Event\EventDispatcherTrait; |
| 19 | +use Cake\ORM\Query; |
19 | 20 | use Cake\Utility\Hash; |
20 | 21 | use CakeDC\Users\Exception\AccountNotActiveException; |
21 | 22 | use CakeDC\Users\Exception\MissingEmailException; |
@@ -138,7 +139,6 @@ protected function _createSocialUser($data, $options = []) |
138 | 139 | $useEmail = $options['use_email'] ?? null; |
139 | 140 | $validateEmail = $options['validate_email'] ?? null; |
140 | 141 | $tokenExpiration = $options['token_expiration'] ?? null; |
141 | | - $existingUser = null; |
142 | 142 | $email = $data['email'] ?? null; |
143 | 143 | if ($useEmail && empty($email)) { |
144 | 144 | throw new MissingEmailException(__d('cake_d_c/users', 'Email not present')); |
@@ -276,8 +276,15 @@ public function generateUniqueUsername($username) |
276 | 276 | * @param array $options Find options with email key. |
277 | 277 | * @return \Cake\ORM\Query |
278 | 278 | */ |
279 | | - public function findExistingForSocialLogin(\Cake\ORM\Query $query, array $options) |
| 279 | + public function findExistingForSocialLogin(Query $query, array $options) |
280 | 280 | { |
| 281 | + if (!array_key_exists('email', $options)) { |
| 282 | + throw new MissingEmailException(__d('cake_d_c/users', 'Missing `email` option in options array')); |
| 283 | + } |
| 284 | + if (!$options['email']) { |
| 285 | + return $query->where('1 != 1'); |
| 286 | + } |
| 287 | + |
281 | 288 | return $query->where([ |
282 | 289 | $this->_table->aliasField('email') => $options['email'], |
283 | 290 | ]); |
|
0 commit comments