Skip to content

Commit 700ed2d

Browse files
cleanup migrateHash. Use better parameter names to avoid conflict with global .
1 parent 1f8fc96 commit 700ed2d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

web/includes/auth.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ function password_type($password) {
3939

4040
// this function migrates mysql hashing to bcrypt, if you are using PHP >= 5.5
4141
// will be called after successful login, only if mysql hashing is detected
42-
function migrateHash($user, $pass) {
42+
function migrateHash($username, $password) {
4343
if ( function_exists('password_hash') ) {
44-
ZM\Info("Migrating $user to bcrypt scheme");
44+
global $user;
45+
ZM\Info("Migrating $username to bcrypt scheme");
4546
// let it generate its own salt, and ensure bcrypt as PASSWORD_DEFAULT may change later
4647
// we can modify this later to support argon2 etc as switch to its own password signature detection
47-
$bcrypt_hash = password_hash($pass, PASSWORD_BCRYPT);
48-
//ZM\Info ("hased bcrypt $pass is $bcrypt_hash");
49-
$update_password_sql = 'UPDATE Users SET Password=\''.$bcrypt_hash.'\' WHERE Username=\''.$user.'\'';
50-
dbQuery($update_password_sql);
48+
$bcrypt_hash = password_hash($password, PASSWORD_BCRYPT);
49+
dbQuery('UPDATE Users SET Password=? WHERE Username=?', array($bcrypt_hash, $username));
5150
$user['Password'] = $bcrypt_hash;
5251
# Since password field has changed, existing auth_hash is no longer valid
5352
generateAuthHash(ZM_AUTH_HASH_IPS, true);

0 commit comments

Comments
 (0)