From 7984cd17a6db0f2978e8ce37c15f5557cd724395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Wed, 15 Feb 2017 16:25:02 +0100 Subject: [PATCH] Fixes #5364 Reload user before calling postlock hook so that userLocked has the correct value --- include/password-methods/class_password-methods.inc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/password-methods/class_password-methods.inc b/include/password-methods/class_password-methods.inc index b7d9a1661..f011b906e 100644 --- a/include/password-methods/class_password-methods.inc +++ b/include/password-methods/class_password-methods.inc @@ -158,14 +158,15 @@ class passwordMethod // (Un)lock SSH keys lock_ssh_account($mode, $attrs, $modify); - // (Un)lock the account by modifying the password hash. - $pwdClass = new user($dn); - $errors = $pwdClass->callHook('PRE'.$mode, array(), $ret); + // Call pre hooks + $userClass = new user($dn); + $errors = $userClass->callHook('PRE'.$mode, array(), $ret); if (!empty($errors)) { msg_dialog::displayChecks($errors); return FALSE; } + // (Un)lock the account by modifying the password hash. if ($mode == 'LOCK') { /* Lock entry */ $pwd = preg_replace("/(^[^\}]+\})(.*$)/", "\\1!\\2", $pwd); @@ -173,13 +174,14 @@ class passwordMethod /* Unlock entry */ $pwd = preg_replace("/(^[^\}]+\})!(.*$)/", "\\1\\2", $pwd); } - $modify["userPassword"] = $pwd; + $modify['userPassword'] = $pwd; $ldap->cd($dn); $ldap->modify($modify); // Call the password post-lock hook, if defined. if ($ldap->success()) { - $errors = $pwdClass->callHook('POST'.$mode, array(), $ret); + $userClass = new user($dn); + $errors = $userClass->callHook('POST'.$mode, array(), $ret); if (!empty($errors)) { msg_dialog::displayChecks($errors); } -- GitLab