diff --git a/src/User.php b/src/User.php index 6bca5c4fb5b..17ac1b493d2 100644 --- a/src/User.php +++ b/src/User.php @@ -838,6 +838,14 @@ public function computeCloneName( ); } + public function pre_addInDB() + { + // Hash user_dn if set + if (isset($this->input['user_dn']) && is_string($this->input['user_dn']) && strlen($this->input['user_dn']) > 0) { + $this->input['user_dn_hash'] = md5($this->input['user_dn']); + } + } + public function post_addItem() { @@ -895,14 +903,6 @@ public function post_addItem() $right->add($affectation); } } - - // Hash user_dn if set - if (isset($this->input['user_dn']) && is_string($this->input['user_dn']) && strlen($this->input['user_dn']) > 0) { - $this->update([ - 'id' => $this->fields['id'], - 'user_dn_hash' => md5($this->input['user_dn']) - ]); - } } @@ -1198,18 +1198,8 @@ public function post_updateItem($history = true) true ); } - - // Hash user_dn if is updated - if (in_array('user_dn', $this->updates)) { - $this->update([ - 'id' => $this->fields['id'], - 'user_dn_hash' => is_string($this->fields['user_dn']) && strlen($this->fields['user_dn']) > 0 ? md5($this->fields['user_dn']) : null, - ]); - } } - - /** * Apply rules to determine dynamic rights of the user. * @@ -3504,6 +3494,12 @@ public function pre_updateInDB() unset($this->oldvalues['comment']); } } + + // Hash user_dn if is updated + if (in_array('user_dn', $this->updates)) { + $this->updates[] = 'user_dn_hash'; + $this->fields['user_dn_hash'] = is_string($this->input['user_dn']) && strlen($this->input['user_dn']) > 0 ? md5($this->input['user_dn']) : null; + } } public function getSpecificMassiveActions($checkitem = null)