diff options
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/config/passwords.yml | 8 | ||||
-rw-r--r-- | phpBB/phpbb/passwords/manager.php | 25 |
2 files changed, 28 insertions, 5 deletions
diff --git a/phpBB/config/passwords.yml b/phpBB/config/passwords.yml index 511f10c31c..4eeca4e34f 100644 --- a/phpBB/config/passwords.yml +++ b/phpBB/config/passwords.yml @@ -1,5 +1,9 @@ parameters: - passwords.algorithm: passwords.driver.bcrypt_2y + passwords.algorithms: + - passwords.driver.bcrypt_2y + - passwords.driver.bcrypt + - passwords.driver.salted_md5 + - passwords.driver.phpass services: passwords.driver.bcrypt: @@ -60,7 +64,7 @@ services: - @config - @passwords.driver_collection - @passwords.helper - - %passwords.algorithm% + - %passwords.algorithms% passwords.helper: class: phpbb\passwords\helper diff --git a/phpBB/phpbb/passwords/manager.php b/phpBB/phpbb/passwords/manager.php index 0c9eb4f067..8abe7b9f79 100644 --- a/phpBB/phpbb/passwords/manager.php +++ b/phpBB/phpbb/passwords/manager.php @@ -63,15 +63,34 @@ class manager * @param array $hashing_algorithms Hashing driver * service collection * @param phpbb\passwords\helper $helper Passwords helper object - * @param string $default Default driver name + * @param string $defaults List of default driver types */ - public function __construct(\phpbb\config\config $config, $hashing_algorithms, \phpbb\passwords\helper $helper, $default) + public function __construct(\phpbb\config\config $config, $hashing_algorithms, \phpbb\passwords\helper $helper, $defaults) { $this->config = $config; - $this->type = $default; $this->fill_type_map($hashing_algorithms); $this->load_passwords_helper($helper); + $this->register_default_type($defaults); + } + + /** + * Register default type + * Will register the first supported type from the list of default types + * + * @param array $defaults List of default types in order from first to + * use to last to use + */ + protected function register_default_type($defaults) + { + foreach ($defaults as $type) + { + if ($this->algorithms[$type]->is_supported()) + { + $this->type = $type; + break; + } + } } /** |