[Web] Fix password policy for mailbox user; minor Solr status fix

master
andryyy 2021-06-17 07:07:48 +02:00
parent 620b829cf8
commit 9773d3549e
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
2 changed files with 22 additions and 33 deletions

View File

@ -80,7 +80,7 @@ $xmpp_status = xmpp_control('status');
<p><?=$lang['debug']['jvm_memory_solr'];?>: <?=$solr_status['jvm']['memory']['total'] - $solr_status['jvm']['memory']['free'];?> / <?=$solr_status['jvm']['memory']['total'];?> <p><?=$lang['debug']['jvm_memory_solr'];?>: <?=$solr_status['jvm']['memory']['total'] - $solr_status['jvm']['memory']['free'];?> / <?=$solr_status['jvm']['memory']['total'];?>
(<?=round($solr_status['jvm']['memory']['raw']['used%']);?>%)</p> (<?=round($solr_status['jvm']['memory']['raw']['used%']);?>%)</p>
<hr> <hr>
<p><?=$lang['debug']['uptime'];?>: ~<?=round($solr_status['status']['dovecot-fts']['uptime'] / 1000 / 60 / 60);?>h</p> <p><?=$lang['debug']['uptime'];?>: <?=round($solr_status['status']['dovecot-fts']['uptime'] / 1000 / 60 / 60);?>h</p>
<p><?=$lang['debug']['started_at'];?>: <span class="parse_date"><?=$solr_status['status']['dovecot-fts']['startTime'];?></span></p> <p><?=$lang['debug']['started_at'];?>: <span class="parse_date"><?=$solr_status['status']['dovecot-fts']['startTime'];?></span></p>
<p><?=$lang['debug']['last_modified'];?>: <span class="parse_date"><?=$solr_status['status']['dovecot-fts']['index']['lastModified'];?></span></p> <p><?=$lang['debug']['last_modified'];?>: <span class="parse_date"><?=$solr_status['status']['dovecot-fts']['index']['lastModified'];?></span></p>
<p><?=$lang['debug']['size'];?>: <?=$solr_status['status']['dovecot-fts']['index']['size'];?></p> <p><?=$lang['debug']['size'];?>: <?=$solr_status['status']['dovecot-fts']['index']['size'];?></p>

View File

@ -962,10 +962,6 @@ function edit_user_account($_data) {
); );
return false; return false;
} }
if (isset($_data['user_new_pass']) && isset($_data['user_new_pass2'])) {
$password_new = $_data['user_new_pass'];
$password_new2 = $_data['user_new_pass2'];
}
$stmt = $pdo->prepare("SELECT `password` FROM `mailbox` $stmt = $pdo->prepare("SELECT `password` FROM `mailbox`
WHERE `kind` NOT REGEXP 'location|thing|group' WHERE `kind` NOT REGEXP 'location|thing|group'
AND `username` = :user"); AND `username` = :user");
@ -979,34 +975,27 @@ function edit_user_account($_data) {
); );
return false; return false;
} }
if (isset($password_new) && isset($password_new2)) { if (!empty($_data['user_new_pass']) && !empty($_data['user_new_pass2'])) {
if (!empty($password_new2) && !empty($password_new)) { $password_new = $_data['user_new_pass'];
if ($password_new2 != $password_new) { $password_new2 = $_data['user_new_pass2'];
$_SESSION['return'][] = array( if (password_check($password_new, $password_new2) !== true) {
'type' => 'danger', return false;
'log' => array(__FUNCTION__, $_data_log), }
'msg' => 'password_mismatch' // support pre hashed passwords
); if (preg_match('/^{(ARGON2I|ARGON2ID|BLF-CRYPT|CLEAR|CLEARTEXT|CRYPT|DES-CRYPT|LDAP-MD5|MD5|MD5-CRYPT|PBKDF2|PLAIN|PLAIN-MD4|PLAIN-MD5|PLAIN-TRUNC|PLAIN-TRUNC|SHA|SHA1|SHA256|SHA256-CRYPT|SHA512|SHA512-CRYPT|SMD5|SSHA|SSHA256|SSHA512)}/i', $password)) {
return false; $password_hashed = $password_new;
} }
if (!preg_match('/' . $GLOBALS['PASSWD_REGEP'] . '/', $password_new)) { else {
$_SESSION['return'][] = array( $password_hashed = hash_password($password_new);
'type' => 'danger', }
'log' => array(__FUNCTION__, $_data_log), $stmt = $pdo->prepare("UPDATE `mailbox` SET `password` = :password_hashed,
'msg' => 'password_complexity' `attributes` = JSON_SET(`attributes`, '$.force_pw_update', '0'),
); `attributes` = JSON_SET(`attributes`, '$.passwd_update', NOW())
return false; WHERE `username` = :username");
} $stmt->execute(array(
$password_hashed = hash_password($password_new); ':password_hashed' => $password_hashed,
$stmt = $pdo->prepare("UPDATE `mailbox` SET `password` = :password_hashed, ':username' => $username
`attributes` = JSON_SET(`attributes`, '$.force_pw_update', '0'), ));
`attributes` = JSON_SET(`attributes`, '$.passwd_update', NOW())
WHERE `username` = :username");
$stmt->execute(array(
':password_hashed' => $password_hashed,
':username' => $username
));
}
} }
update_sogo_static_view(); update_sogo_static_view();
$_SESSION['return'][] = array( $_SESSION['return'][] = array(