IPB4: Add support for BCrypt passwords
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 27 Jan 2022 14:44:58 +0000 (15:44 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 27 Jan 2022 14:44:58 +0000 (15:44 +0100)
files/lib/system/exporter/IPB4xExporter.class.php

index 1485697f8bbcfe7973392035df3436459dfc1a02..402eb0049ff05b8500fe9b1c2f6291353b9812f4 100644 (file)
@@ -353,8 +353,14 @@ class IPB4xExporter extends AbstractExporter
 
             // update password hash
             if ($newUserID) {
+                if (StringUtil::startsWith($row['members_pass_hash'], '$2')) {
+                    $password = 'Bcrypt:' . $row['members_pass_hash'];
+                } else {
+                    $password = 'cryptMD5:' . $row['members_pass_hash'] . ':' . ($row['members_pass_salt'] ?: '');
+                }
+
                 $passwordUpdateStatement->execute([
-                    'cryptMD5:' . $row['members_pass_hash'] . ':' . $row['members_pass_salt'],
+                    $password,
                     $newUserID,
                 ]);
             }