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

Commit

Permalink
fix(Admin/User): don't add email user without email address
Browse files Browse the repository at this point in the history
Change-Id: I7d4bca6ce102bba4e625e0f72178abec46f6fc97
Reviewed-on: http://gerrit.tine20.com/customers/18617
Tested-by: Jenkins CI (http://ci.tine20.com/) <tine20-jenkins@metaways.de>
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
  • Loading branch information
pschuele committed Dec 1, 2020
1 parent 932ffe3 commit e08eccb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/tine20/Admin/Frontend/Json/UserTest.php
Expand Up @@ -168,6 +168,20 @@ public function testSaveAccountWithExistingName()
}
}

public function testSaveAccountWithoutEmail()
{
$this->_skipWithoutEmailSystemAccountConfig();

$accountData = $this->_getUserArrayWithPw();
unset($accountData['accountEmailAddress']);
$account = $this->_json->saveUser($accountData);

self::assertEmpty($account['accountEmailAddress']);
// assert no email account has been created
self::assertFalse(isset($account['xprops'][Tinebase_Model_FullUser::XPROP_EMAIL_USERID_IMAP]), 'imap user found!');
self::assertFalse(isset($account['xprops'][Tinebase_Model_FullUser::XPROP_EMAIL_USERID_SMTP]), 'smtp user found!');
}

/**
* try to save a hidden account
*/
Expand Down
5 changes: 5 additions & 0 deletions tine20/Tinebase/User/Sql.php
Expand Up @@ -980,6 +980,11 @@ protected function _inspectCRUD($plugin, $user, $newUserProperties, $method)

// add email user xprops here if configured
if (Tinebase_EmailUser::isEmailUserPlugin($plugin) && Tinebase_Config::getInstance()->{Tinebase_Config::EMAIL_USER_ID_IN_XPROPS}) {
if ($method === 'inspectAddUser' && empty($user->accountEmailAddress)) {
// do not add plugin user if user has no email adress
return;
}

$pluginUser = clone($user);
Tinebase_EmailUser_XpropsFacade::setIdFromXprops($user, $pluginUser, $method !== 'inspectGetUserByProperty');
if ($newUserProperties) {
Expand Down

0 comments on commit e08eccb

Please sign in to comment.