mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
Merge pull request #6659 from rxu/ticket/17351-master
[ticket/17351] Correctly handle md5 passwords rehashing - master
This commit is contained in:
commit
13f2f44825
2 changed files with 16 additions and 0 deletions
|
@ -101,6 +101,14 @@ class update_hashes extends \phpbb\console\command\command
|
|||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$old_hash = preg_replace('/^\$CP\$/', '', $row['user_password']);
|
||||
|
||||
// If stored hash type is unknown then it's md5 hash with no prefix
|
||||
// First rehash it using $H$ as hash type identifier (salted_md5)
|
||||
if (!$this->passwords_manager->detect_algorithm($old_hash))
|
||||
{
|
||||
$old_hash = $this->passwords_manager->hash($old_hash, '$H$');
|
||||
}
|
||||
|
||||
$new_hash = $this->passwords_manager->hash($old_hash, [$this->default_type]);
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . "
|
||||
|
|
|
@ -107,6 +107,14 @@ class update_hashes extends \phpbb\cron\task\base
|
|||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$old_hash = preg_replace('/^\$CP\$/', '', $row['user_password']);
|
||||
|
||||
// If stored hash type is unknown then it's md5 hash with no prefix
|
||||
// First rehash it using $H$ as hash type identifier (salted_md5)
|
||||
if (!$this->passwords_manager->detect_algorithm($old_hash))
|
||||
{
|
||||
$old_hash = $this->passwords_manager->hash($old_hash, '$H$');
|
||||
}
|
||||
|
||||
$new_hash = $this->passwords_manager->hash($old_hash, [$this->default_type]);
|
||||
|
||||
// Increase number so we know that users were selected from the database
|
||||
|
|
Loading…
Add table
Reference in a new issue