Skip to content

Commit 4dfef9f

Browse files
🔃 [EngCom] Public Pull Requests - 2.1-develop
Accepted Public Pull Requests: - #14168: [Backport 2.1] Added mage/translate component to customers's ajax login (by @ccasciotti) - #13886: #5463 - Use specified hashing algo in \Magento\Framework\Encryption\Encryptor::getHash (by @k4emic) Fixed GitHub Issues: - #5463: The ability to store passwords using different hashing algorithms is limited (reported by @maderlock) has been fixed in #13886 by @k4emic in 2.1-develop branch Related commits: 1. 86dd6ec
2 parents 00d657a + 000fe3f commit 4dfef9f

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

app/code/Magento/Customer/view/frontend/web/js/action/login.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ define(
88
'jquery',
99
'mage/storage',
1010
'Magento_Ui/js/model/messageList',
11-
'Magento_Customer/js/customer-data'
11+
'Magento_Customer/js/customer-data',
12+
'mage/translate'
1213
],
13-
function($, storage, globalMessageList, customerData) {
14+
function($, storage, globalMessageList, customerData, $t) {
1415
'use strict';
1516
var callbacks = [],
1617
action = function(loginData, redirectUrl, isGlobal, messageContainer) {
@@ -39,7 +40,9 @@ define(
3940
}
4041
}
4142
}).fail(function () {
42-
messageContainer.addErrorMessage({'message': 'Could not authenticate. Please try again later'});
43+
messageContainer.addErrorMessage({
44+
'message': $t('Could not authenticate. Please try again later')
45+
});
4346
callbacks.forEach(function(callback) {
4447
callback(loginData);
4548
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function validateCipher($version)
143143
public function getHash($password, $salt = false, $version = self::HASH_VERSION_LATEST)
144144
{
145145
if ($salt === false) {
146-
return $this->hash($password);
146+
return $this->hash($password, $version);
147147
}
148148
if ($salt === true) {
149149
$salt = self::DEFAULT_SALT_LENGTH;
@@ -155,7 +155,7 @@ public function getHash($password, $salt = false, $version = self::HASH_VERSION_
155155
return implode(
156156
self::DELIMITER,
157157
[
158-
$this->hash($salt . $password),
158+
$this->hash($salt . $password, $version),
159159
$salt,
160160
$version
161161
]

lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,32 @@ public function testValidateKey()
207207
$this->assertEquals($expectedEncryptedData, $actualEncryptedData);
208208
$this->assertEquals($crypt->decrypt($expectedEncryptedData), $actual->decrypt($actualEncryptedData));
209209
}
210+
211+
public function testUseSpecifiedHashingAlgoDataProvider()
212+
{
213+
return [
214+
['password', 'salt', Encryptor::HASH_VERSION_MD5,
215+
'67a1e09bb1f83f5007dc119c14d663aa:salt:0'],
216+
['password', 'salt', Encryptor::HASH_VERSION_SHA256,
217+
'13601bda4ea78e55a07b98866d2be6be0744e3866f13c00c811cab608a28f322:salt:1'],
218+
['password', false, Encryptor::HASH_VERSION_MD5,
219+
'5f4dcc3b5aa765d61d8327deb882cf99'],
220+
['password', false, Encryptor::HASH_VERSION_SHA256,
221+
'5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8']
222+
];
223+
}
224+
225+
/**
226+
* @dataProvider testUseSpecifiedHashingAlgoDataProvider
227+
*
228+
* @param $password
229+
* @param $salt
230+
* @param $hashAlgo
231+
* @param $expected
232+
*/
233+
public function testGetHashMustUseSpecifiedHashingAlgo($password, $salt, $hashAlgo, $expected)
234+
{
235+
$hash = $this->_model->getHash($password, $salt, $hashAlgo);
236+
$this->assertEquals($expected, $hash);
237+
}
210238
}

0 commit comments

Comments
 (0)