Skip to content

Commit

Permalink
Fix install issue with empty password
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanheywood committed Aug 16, 2023
1 parent 2e89ed1 commit d30f95b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions classes/admin_setting_configpasswordhashed.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public function write_setting($data) {
if (empty($data)) {
// Password field is empty so just reuse existing hash.
$password = $this->config_read($this->name);

// If it is null then it is a fresh install so save an empty string.
if ($password === null) {
$password = '';
}
} else {
// Hash new password.
$password = password_hash($data, PASSWORD_DEFAULT);
Expand All @@ -87,6 +92,9 @@ public function write_setting($data) {
* @return mixed true if ok string if error found
*/
public function validate($data) {
if ($data === '') {
return true;
}
if (empty($data) || (is_string($data) && (strlen($data) >= $this->minlength))) {
return true;
}
Expand Down

0 comments on commit d30f95b

Please sign in to comment.