Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Model/Behavior/SocialBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ protected function _populateUser($data, $existingUser, $useEmail, $validateEmail
$email = explode('@', $dataEmail);
$userData['username'] = Hash::get($email, 0);
} else {
$firstName = $userData['first_name'] ?? null;
$firstName = $userData['first_name'];
$lastName = $userData['last_name'];
$userData['username'] = strtolower($firstName . $lastName);
$userData['username'] = preg_replace('/[^A-Za-z0-9]/i', '', $userData['username']);
}
}

$userData['username'] = $this->generateUniqueUsername($userData['username'] ?? null);
$userData['username'] = $this->generateUniqueUsername($userData['username']);
if ($useEmail) {
$userData['email'] = $data['email'] ?? null;
if (empty($dataValidated)) {
Expand Down
25 changes: 4 additions & 21 deletions tests/TestCase/Controller/Traits/ReCaptchaTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Cake\Core\Configure;
use Cake\TestSuite\TestCase;
use ReCaptcha\Response;
use ReflectionMethod;

class ReCaptchaTraitTest extends TestCase
Expand Down Expand Up @@ -58,13 +59,7 @@ public function testValidateValidReCaptcha()
->onlyMethods(['verify'])
->disableOriginalConstructor()
->getMock();
$Response = $this->getMockBuilder('ReCaptcha\Response')
->onlyMethods(['isSuccess'])
->disableOriginalConstructor()
->getMock();
$Response->expects($this->once())
->method('isSuccess')
->will($this->returnValue(true));
$Response = new Response(true);
$ReCaptcha->expects($this->once())
->method('verify')
->with('value')
Expand All @@ -87,13 +82,7 @@ public function testValidateInvalidReCaptcha()
->onlyMethods(['verify'])
->disableOriginalConstructor()
->getMock();
$Response = $this->getMockBuilder('ReCaptcha\Response')
->onlyMethods(['isSuccess'])
->disableOriginalConstructor()
->getMock();
$Response->expects($this->once())
->method('isSuccess')
->will($this->returnValue(false));
$Response = new Response(false);
$ReCaptcha->expects($this->once())
->method('verify')
->with('invalid')
Expand Down Expand Up @@ -130,13 +119,7 @@ public function testValidateReCaptchaFalse()
->onlyMethods(['verify'])
->disableOriginalConstructor()
->getMock();
$Response = $this->getMockBuilder('ReCaptcha\Response')
->onlyMethods(['isSuccess'])
->disableOriginalConstructor()
->getMock();
$Response->expects($this->once())
->method('isSuccess')
->will($this->returnValue(false));
$Response = new Response(false);
$ReCaptcha->expects($this->once())
->method('verify')
->with('value')
Expand Down
Loading