summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-06-27 16:10:32 +0200
committerGitHub <noreply@github.com>2019-06-27 16:10:32 +0200
commitac486b003b87334320c9efc2df0509213dd19c84 (patch)
tree8d29f6d046ea987b4b6422546369da1ea155e557
parente4d88bd47d5726d5ad47d27b3fd2ed304105f591 (diff)
parenta9c2a4285c508e5bf58faefadeb6a1c7bcda83c6 (diff)
downloadnextcloud-server-ac486b003b87334320c9efc2df0509213dd19c84.tar.gz
nextcloud-server-ac486b003b87334320c9efc2df0509213dd19c84.zip
Merge pull request #16113 from nextcloud/backport/16101/stable15
[stable15] invalidates user when plugin reported deletion success
-rw-r--r--apps/user_ldap/lib/Group_LDAP.php13
-rw-r--r--apps/user_ldap/lib/User_LDAP.php9
-rw-r--r--apps/user_ldap/tests/User_LDAPTest.php22
3 files changed, 37 insertions, 7 deletions
diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php
index 0780e28f740..2ce35c8f0ef 100644
--- a/apps/user_ldap/lib/Group_LDAP.php
+++ b/apps/user_ldap/lib/Group_LDAP.php
@@ -1133,8 +1133,17 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
if ($this->groupPluginManager->implementsActions(GroupInterface::CREATE_GROUP)) {
if ($dn = $this->groupPluginManager->createGroup($gid)) {
//updates group mapping
- $this->access->dn2ocname($dn, $gid, false);
- $this->access->connection->writeToCache("groupExists".$gid, true);
+ $uuid = $this->access->getUUID($dn, false);
+ if(is_string($uuid)) {
+ $this->access->mapAndAnnounceIfApplicable(
+ $this->access->getGroupMapper(),
+ $dn,
+ $gid,
+ $uuid,
+ false
+ );
+ $this->access->connection->writeToCache("groupExists" . $gid, true);
+ }
}
return $dn != null;
}
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index 8e5a4fe8e36..60ade85a0e4 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -384,18 +384,21 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
*/
public function deleteUser($uid) {
if ($this->userPluginManager->canDeleteUser()) {
- return $this->userPluginManager->deleteUser($uid);
+ $status = $this->userPluginManager->deleteUser($uid);
+ if($status === false) {
+ return false;
+ }
}
$marked = $this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0);
if((int)$marked === 0) {
\OC::$server->getLogger()->notice(
'User '.$uid . ' is not marked as deleted, not cleaning up.',
- array('app' => 'user_ldap'));
+ ['app' => 'user_ldap']);
return false;
}
\OC::$server->getLogger()->info('Cleaning up after user ' . $uid,
- array('app' => 'user_ldap'));
+ ['app' => 'user_ldap']);
$this->access->getUserMapper()->unmap($uid); // we don't emit unassign signals here, since it is implicit to delete signals fired from core
$this->access->userManager->invalidate($uid);
diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php
index e4f7bb8b6d2..b89d6816c5a 100644
--- a/apps/user_ldap/tests/User_LDAPTest.php
+++ b/apps/user_ldap/tests/User_LDAPTest.php
@@ -342,9 +342,27 @@ class User_LDAPTest extends TestCase {
$this->pluginManager->expects($this->once())
->method('deleteUser')
->with('uid')
- ->willReturn('result');
+ ->willReturn(true);
+
+ $this->config->expects($this->once())
+ ->method('getUserValue')
+ ->with('uid', 'user_ldap', 'isDeleted', 0)
+ ->willReturn(1);
+
+ $mapper = $this->createMock(UserMapping::class);
+ $mapper->expects($this->once())
+ ->method('unmap')
+ ->with('uid');
+
+ $this->access->expects($this->atLeastOnce())
+ ->method('getUserMapper')
+ ->willReturn($mapper);
+
+ $this->userManager->expects($this->once())
+ ->method('invalidate')
+ ->with('uid');
- $this->assertEquals($this->backend->deleteUser('uid'),'result');
+ $this->assertEquals(true, $this->backend->deleteUser('uid'));
}
/**