CakeDC / users

Users Plugin for CakePHP
https://www.cakedc.com
Other
521 stars 296 forks source link

Problem with named parameters in _createSocialUser method for find in CakePHP (Model/Behavior/SocialBehavior.php) #1090

Closed robitmoh closed 4 months ago

robitmoh commented 4 months ago

The _createSocialUser method in our CakePHP project uses a named parameter "options" when calling the find method, which causes issues with parameter parsing. Specifically, the findExistingForSocialLogin custom finder does not correctly retrieve the 'email' parameter, resulting in incorrect query construction.

Proposed Solution: Modify the _createSocialUser method to pass parameters directly to the find method without using a named parameter

from:
$existingUser = $this->_table->find('existingForSocialLogin', options: ['email' => $email])->first();
to:
$existingUser = $this->_table->find('existingForSocialLogin', ['email' => $email])->first();

public function findExistingForSocialLogin(\Cake\ORM\Query\SelectQuery $query, array $options)
{
    return $query->where([
        $this->_table->aliasField('email') => $options['email'],
    ]);
}