move code to update/add user into protected function

This commit is contained in:
Uwe Steinmann 2023-08-16 18:45:20 +02:00
parent 7b8f3ef0bb
commit 5de8c66d1f

View File

@ -28,6 +28,19 @@ class SeedDMS_LdapAuthentication extends SeedDMS_Authentication {
var $settings;
protected function addUser($username, $info) {
return $dms->addUser($username, null, $info['cn'][0], $info['mail'][0], $settings->_language, $settings->_theme, "", 0);
}
protected function updateUser($user, $info) {
if(isset($info['cn'][0]) && ($info['cn'][0] != $user->getFullName())) {
$user->setFullName($info['cn'][0]);
}
if(isset($info['mail'][0]) && ($info['mail'][0] != $user->getEmail())) {
$user->setEmail($info['mail'][0]);
}
}
public function __construct($dms, $settings) { /* {{{ */
$this->dms = $dms;
$this->settings = $settings;
@ -131,10 +144,6 @@ class SeedDMS_LdapAuthentication extends SeedDMS_Authentication {
return false;
}
<<<<<<< Updated upstream
if (!is_bool($info) && $info["count"]==1 && $info[0]["count"]>0) {
$user = $dms->addUser($username, null, $info[0]['cn'][0], $info[0]['mail'][0], $settings->_language, $settings->_theme, "", 0);
=======
// Successfully authenticated. Now check to see if the user exists within
// the database. If not, add them in if _restricted is not set,
// but do not add their password.
@ -151,15 +160,9 @@ class SeedDMS_LdapAuthentication extends SeedDMS_Authentication {
if (!is_bool($info) && $info["count"]==1 && $info[0]["count"]>0) {
if (is_null($user)) {
$user = $dms->addUser($username, null, $info[0]['cn'][0], $info[0]['mail'][0], $settings->_language, $settings->_theme, "", 3);
$user = $this->addUser($username, $info[0]);
} else {
if(isset($info[0]['cn'][0]) && ($info[0]['cn'][0] != $user->getFullName())) {
$user->setFullName($info[0]['cn'][0]);
}
if(isset($info[0]['mail'][0]) && ($info[0]['mail'][0] != $user->getEmail())) {
$user->setEmail($info[0]['mail'][0]);
}
>>>>>>> Stashed changes
$this->updateUser($user, $info[0]);
}
}
}