Skip to content

Commit 5d24719

Browse files
author
Leonix
committed
This merges pull request #348
Squashed commit of the following: commit 9999ce9 Author: Di Elshin <[email protected]> Date: Thu Mar 17 17:36:57 2022 +0300 Update waVerificationChannelSMS.class.php commit cf44051 Author: Di Elshin <[email protected]> Date: Thu Mar 17 16:58:41 2022 +0300 Update waVerificationChannelSMS.class.php commit 1ef7b4d Author: Di Elshin <[email protected]> Date: Thu Mar 17 16:57:31 2022 +0300 Update waVerificationChannelEmail.class.php commit 1a2d011 Author: Dmitry Elshin <[email protected]> Date: Tue Dec 14 14:56:21 2021 +0300 Calling a custom function to validate the password hash (wa_password_verify)
1 parent 766cfc4 commit 5d24719

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

wa-system/auth/waAuth.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ protected function isOnetimePasswordMode()
699699
protected function _authByPassword($contact, $password)
700700
{
701701
$contact_password = isset($contact['password']) && is_scalar($contact['password']) ? $contact['password'] : '';
702-
return strlen($contact_password) > 0 && waContact::getPasswordHash($password) === $contact_password;
702+
return strlen($contact_password) > 0 && waContact::verifyPasswordHash($password, $contact_password);
703703
}
704704

705705
/**

wa-system/contact/waContact.class.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,25 @@ public static function getPasswordHash($password)
13241324
}
13251325
}
13261326

1327+
/**
1328+
* Verifies the password hash.
1329+
*
1330+
* By default, strict comparison is used. If configuration file wa-config/SystemConfig.class.php
1331+
* contains information about user-defined function wa_password_verify(), then that function is used for hash verification.
1332+
*
1333+
* @param string$password
1334+
* @param string $hash
1335+
* @return bool
1336+
*/
1337+
public static function verifyPasswordHash($password, $hash)
1338+
{
1339+
if (function_exists('wa_password_verify')) {
1340+
return (bool) wa_password_verify($password, $hash);
1341+
} else {
1342+
return waContact::getPasswordHash($password) === $hash;
1343+
}
1344+
}
1345+
13271346
/**
13281347
* @param int $len
13291348
* @param bool $extended - use extended alphabet or only letters and digits

wa-system/verification/classes/waVerificationChannelEmail.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ protected function isSecretEquals($input_secret, $asset_secret, $asset_name)
866866
if ($asset_name === waVerificationChannelAssetsModel::NAME_PASSWORD_RECOVERY_HASH || $asset_name === waVerificationChannelAssetsModel::NAME_SIGNUP_CONFIRM_HASH) {
867867
return $input_secret === $asset_secret;
868868
} else {
869-
return waContact::getPasswordHash($input_secret) === $asset_secret;
869+
return waContact::verifyPasswordHash($input_secret, $asset_secret);
870870
}
871871
}
872872

wa-system/verification/classes/waVerificationChannelSMS.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ protected function isAddressEquals($address1, $address2)
185185

186186
protected function isSecretEquals($input_secret, $asset_secret, $asset_name)
187187
{
188-
return waContact::getPasswordHash($input_secret) === $asset_secret;
188+
return waContact::verifyPasswordHash($input_secret, $asset_secret);
189189
}
190190

191191

0 commit comments

Comments
 (0)