Skip to content

Commit 29ae484

Browse files
author
Joan He
committed
Merge remote-tracking branch 'trigger/MAGETWO-95876' into BugFixPR
2 parents a8392fb + 893652b commit 29ae484

File tree

4 files changed

+72
-4
lines changed

4 files changed

+72
-4
lines changed

app/code/Magento/Customer/Model/Authentication.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ public function isLocked($customerId)
166166
public function authenticate($customerId, $password)
167167
{
168168
$customerSecure = $this->customerRegistry->retrieveSecureData($customerId);
169-
$hash = $customerSecure->getPasswordHash();
170-
if (!$hash || !$this->encryptor->validateHash($password, $hash)) {
169+
$hash = $customerSecure->getPasswordHash() ?? '';
170+
if (!$this->encryptor->validateHash($password, $hash)) {
171171
$this->processAuthenticationFailure($customerId);
172172
if ($this->isLocked($customerId)) {
173173
throw new UserLockedException(__('The account is locked.'));

dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,35 @@ public function testIndexAction()
5656
$this->assertContains('Green str, 67', $body);
5757
}
5858

59+
/**
60+
* @magentoDataFixture Magento/Customer/_files/customer_no_password.php
61+
*/
62+
public function testLoginWithIncorrectPassword()
63+
{
64+
$expectedMessage = 'The account sign-in was incorrect or your account is disabled temporarily. '
65+
. 'Please wait and try again later.';
66+
$this->getRequest()
67+
->setMethod('POST')
68+
->setPostValue(
69+
[
70+
'login' => [
71+
'username' => 'customer@example.com',
72+
'password' => '123123q'
73+
]
74+
]
75+
);
76+
77+
$this->dispatch('customer/account/loginPost');
78+
$this->assertRedirect($this->stringContains('customer/account/login'));
79+
$this->assertSessionMessages(
80+
$this->equalTo(
81+
[
82+
$expectedMessage
83+
]
84+
)
85+
);
86+
}
87+
5988
/**
6089
* Test sign up form displaying.
6190
*/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
use Magento\Customer\Model\CustomerRegistry;
7+
8+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
9+
/** @var $repository \Magento\Customer\Api\CustomerRepositoryInterface */
10+
$repository = $objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class);
11+
$customer = $objectManager->create(\Magento\Customer\Model\Customer::class);
12+
/** @var CustomerRegistry $customerRegistry */
13+
$customerRegistry = $objectManager->get(CustomerRegistry::class);
14+
/** @var Magento\Customer\Model\Customer $customer */
15+
$customer->setWebsiteId(1)
16+
->setId(1)
17+
->setEmail('customer@example.com')
18+
->setGroupId(1)
19+
->setStoreId(1)
20+
->setIsActive(1)
21+
->setPrefix('Mr.')
22+
->setFirstname('John')
23+
->setMiddlename('A')
24+
->setLastname('Smith')
25+
->setSuffix('Esq.')
26+
->setDefaultBilling(1)
27+
->setDefaultShipping(1)
28+
->setTaxvat('12')
29+
->setGender(0);
30+
31+
$customer->isObjectNew(true);
32+
$customer->save();
33+
$customerRegistry->remove($customer->getId());

lib/internal/Magento/Framework/Encryption/Encryptor.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function validateHashVersion($hash, $validateCount = false)
228228
}
229229

230230
/**
231-
* Split password hash into parts: hash, salt, version
231+
* Explode password hash
232232
*
233233
* @param string $hash
234234
* @return array
@@ -271,7 +271,13 @@ private function getPasswordSalt()
271271
*/
272272
private function getPasswordVersion()
273273
{
274-
return array_map('intval', explode(self::DELIMITER, $this->passwordHashMap[self::PASSWORD_VERSION]));
274+
return array_map(
275+
'intval',
276+
explode(
277+
self::DELIMITER,
278+
(string)$this->passwordHashMap[self::PASSWORD_VERSION]
279+
)
280+
);
275281
}
276282

277283
/**

0 commit comments

Comments
 (0)