Commit 7984cd17 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #5364 Reload user before calling postlock hook so that userLocked has the correct value

Showing with 7 additions and 5 deletions
+7 -5
...@@ -158,14 +158,15 @@ class passwordMethod ...@@ -158,14 +158,15 @@ class passwordMethod
// (Un)lock SSH keys // (Un)lock SSH keys
lock_ssh_account($mode, $attrs, $modify); lock_ssh_account($mode, $attrs, $modify);
// (Un)lock the account by modifying the password hash. // Call pre hooks
$pwdClass = new user($dn); $userClass = new user($dn);
$errors = $pwdClass->callHook('PRE'.$mode, array(), $ret); $errors = $userClass->callHook('PRE'.$mode, array(), $ret);
if (!empty($errors)) { if (!empty($errors)) {
msg_dialog::displayChecks($errors); msg_dialog::displayChecks($errors);
return FALSE; return FALSE;
} }
// (Un)lock the account by modifying the password hash.
if ($mode == 'LOCK') { if ($mode == 'LOCK') {
/* Lock entry */ /* Lock entry */
$pwd = preg_replace("/(^[^\}]+\})(.*$)/", "\\1!\\2", $pwd); $pwd = preg_replace("/(^[^\}]+\})(.*$)/", "\\1!\\2", $pwd);
...@@ -173,13 +174,14 @@ class passwordMethod ...@@ -173,13 +174,14 @@ class passwordMethod
/* Unlock entry */ /* Unlock entry */
$pwd = preg_replace("/(^[^\}]+\})!(.*$)/", "\\1\\2", $pwd); $pwd = preg_replace("/(^[^\}]+\})!(.*$)/", "\\1\\2", $pwd);
} }
$modify["userPassword"] = $pwd; $modify['userPassword'] = $pwd;
$ldap->cd($dn); $ldap->cd($dn);
$ldap->modify($modify); $ldap->modify($modify);
// Call the password post-lock hook, if defined. // Call the password post-lock hook, if defined.
if ($ldap->success()) { if ($ldap->success()) {
$errors = $pwdClass->callHook('POST'.$mode, array(), $ret); $userClass = new user($dn);
$errors = $userClass->callHook('POST'.$mode, array(), $ret);
if (!empty($errors)) { if (!empty($errors)) {
msg_dialog::displayChecks($errors); msg_dialog::displayChecks($errors);
} }
......
  • bmortier @bmortier

    mentioned in issue #1714 (closed)

    By Côme Chilliet on 2017-09-02T15:35:35 (imported from GitLab)

    ·

    mentioned in issue #1714 (closed)

    By Côme Chilliet on 2017-09-02T15:35:35 (imported from GitLab)

    Toggle commit list
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment