diff --git a/src/Model/Behavior/SocialAccountBehavior.php b/src/Model/Behavior/SocialAccountBehavior.php index a0a84650..f1bfd4cf 100644 --- a/src/Model/Behavior/SocialAccountBehavior.php +++ b/src/Model/Behavior/SocialAccountBehavior.php @@ -38,11 +38,13 @@ class SocialAccountBehavior extends Behavior public function initialize(array $config): void { parent::initialize($config); - $this->_table - ->belongsTo('Users') - ->setForeignKey('user_id') - ->setJoinType('INNER') - ->setClassName(Configure::read('Users.table')); + if (!$this->_table->hasAssociation('Users')) { + $this->_table + ->belongsTo('Users') + ->setForeignKey('user_id') + ->setJoinType('INNER') + ->setClassName(Configure::read('Users.table')); + } } /** diff --git a/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php b/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php index ad20dbae..9ac15300 100644 --- a/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php +++ b/tests/TestCase/Controller/Traits/Integration/LoginTraitIntegrationTest.php @@ -88,8 +88,8 @@ public function testLoginGetRequestNoSocialLogin() $this->assertResponseNotContains('Username or password is incorrect'); $this->assertResponseContains('