Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Revert "feature(Tinebase/EmailUser): set domain in Dovecot backend"
Browse files Browse the repository at this point in the history
the domain in the dovecot backend just is the configured domain
 and has nothing to do with the users email address

This reverts commit b3e58ff.
  • Loading branch information
pschuele committed Jun 1, 2021
1 parent 1215886 commit 01df032
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
3 changes: 2 additions & 1 deletion tests/tine20/Tinebase/User/EmailUser/Imap/DovecotTest.php
Expand Up @@ -300,6 +300,7 @@ public function testAddUserWithSecondaryDomain()
]);
$rawDovecotUser = $this->_getRawDovecotUser($user);
self::assertNotNull($rawDovecotUser, 'could not find dovecot user');
self::assertEquals($secEmailDomain, $rawDovecotUser['domain'], 'secondary domain expected: ' . print_r($rawDovecotUser, true));
self::assertEquals(TestServer::getPrimaryMailDomain(), $rawDovecotUser['domain'],
'primary domain expected: ' . print_r($rawDovecotUser, true));
}
}
19 changes: 6 additions & 13 deletions tine20/Tinebase/EmailUser/Imap/Dovecot.php
Expand Up @@ -341,12 +341,8 @@ protected function _appendDomainOrClientIdOrInstanceToSelect(Zend_Db_Select $sel
$select->where($this->_db->quoteIdentifier($this->_userTable . '.' . 'instancename') . ' = ?',
$this->_config['instanceName']);
} else if (isset($this->_config['domain']) && ! empty($this->_config['domain'])) {
$domains = Tinebase_EmailUser::getAllowedDomains();
if (count($domains) === 0) {
$domains = [$this->_config['domain']];
}
$select->where($this->_db->quoteIdentifier($this->_userTable . '.' . 'domain') . ' IN (?)',
$domains);
$select->where($this->_db->quoteIdentifier($this->_userTable . '.' . 'domain') . ' = ?',
$this->_config['domain']);
} else {
$select->where($this->_db->quoteIdentifier($this->_userTable . '.' . 'domain') . " = ''");
}
Expand Down Expand Up @@ -448,18 +444,15 @@ protected function _recordToRawData(Tinebase_Model_FullUser $_user, Tinebase_Mod

$emailUsername = $this->getEmailUserName($_user, $_newUserProperties->accountEmailAddress);

if (strpos($_newUserProperties->accountEmailAddress, '@') !== false) {
list($localPart, $domain) = explode('@', $_newUserProperties->accountEmailAddress, 2);
} else {
list($localPart, $usernamedomain) = explode('@', $emailUsername, 2);
$domain = empty($this->_config['domain']) ? $usernamedomain : $this->_config['domain'];
}
$rawData['domain'] = $domain;
list($localPart, $usernamedomain) = explode('@', $emailUsername, 2);
$domain = empty($this->_config['domain']) ? $usernamedomain : $this->_config['domain'];

if (isset($this->_config['instanceName'])) {
$rawData['instancename'] = $this->_config['instanceName'];
}

$rawData['domain'] = $domain;

$rawData[$this->_propertyMapping['emailHome']] = $this->_getEmailHome($emailUsername, $localPart, $domain);
$rawData[$this->_propertyMapping['emailUsername']] = $emailUsername;

Expand Down
8 changes: 3 additions & 5 deletions tine20/Tinebase/EmailUser/Sql.php
Expand Up @@ -160,11 +160,7 @@ protected function _appendClientIdOrDomain(&$where = NULL)
$cond = $this->_db->quoteInto($this->_db->quoteIdentifier($this->_userTable . '.' . 'client_idnr') . ' = ?', $this->_clientId);
} else {
if ((isset($this->_config['domain']) || array_key_exists('domain', $this->_config)) && ! empty($this->_config['domain'])) {
$domains = Tinebase_EmailUser::getAllowedDomains();
if (count($domains) === 0) {
$domains = [$this->_config['domain']];
}
$cond = $this->_db->quoteInto($this->_db->quoteIdentifier($this->_userTable . '.' . 'domain') . ' IN (?)', $domains);
$cond = $this->_db->quoteInto($this->_db->quoteIdentifier($this->_userTable . '.' . 'domain') . ' = ?', $this->_config['domain']);
} else {
$cond = $this->_db->quoteIdentifier($this->_userTable . '.' . 'domain') . " =''";
}
Expand Down Expand Up @@ -295,6 +291,8 @@ public function inspectSetPassword($_userId, $_password, $_encrypt = TRUE)
substr($_userId, 0,32) . '#~#%') . ')'
);
$this->_appendClientIdOrDomain($where);
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .
' where: ' . print_r($where, true));

$this->_db->update($this->_userTable, $values, $where);
}
Expand Down

0 comments on commit 01df032

Please sign in to comment.