Skip to content

Commit 66dc4c9

Browse files
authored
Merge pull request #16112 from nextcloud/backport/16101/stable16
[stable16] invalidates user when plugin reported deletion success
2 parents 57bf23c + 41e94f2 commit 66dc4c9

3 files changed

Lines changed: 37 additions & 7 deletions

File tree

apps/user_ldap/lib/Group_LDAP.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,8 +1133,17 @@ public function createGroup($gid) {
11331133
if ($this->groupPluginManager->implementsActions(GroupInterface::CREATE_GROUP)) {
11341134
if ($dn = $this->groupPluginManager->createGroup($gid)) {
11351135
//updates group mapping
1136-
$this->access->dn2ocname($dn, $gid, false);
1137-
$this->access->connection->writeToCache("groupExists".$gid, true);
1136+
$uuid = $this->access->getUUID($dn, false);
1137+
if(is_string($uuid)) {
1138+
$this->access->mapAndAnnounceIfApplicable(
1139+
$this->access->getGroupMapper(),
1140+
$dn,
1141+
$gid,
1142+
$uuid,
1143+
false
1144+
);
1145+
$this->access->connection->writeToCache("groupExists" . $gid, true);
1146+
}
11381147
}
11391148
return $dn != null;
11401149
}

apps/user_ldap/lib/User_LDAP.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,18 +382,21 @@ public function userExists($uid) {
382382
*/
383383
public function deleteUser($uid) {
384384
if ($this->userPluginManager->canDeleteUser()) {
385-
return $this->userPluginManager->deleteUser($uid);
385+
$status = $this->userPluginManager->deleteUser($uid);
386+
if($status === false) {
387+
return false;
388+
}
386389
}
387390

388391
$marked = $this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0);
389392
if((int)$marked === 0) {
390393
\OC::$server->getLogger()->notice(
391394
'User '.$uid . ' is not marked as deleted, not cleaning up.',
392-
array('app' => 'user_ldap'));
395+
['app' => 'user_ldap']);
393396
return false;
394397
}
395398
\OC::$server->getLogger()->info('Cleaning up after user ' . $uid,
396-
array('app' => 'user_ldap'));
399+
['app' => 'user_ldap']);
397400

398401
$this->access->getUserMapper()->unmap($uid); // we don't emit unassign signals here, since it is implicit to delete signals fired from core
399402
$this->access->userManager->invalidate($uid);

apps/user_ldap/tests/User_LDAPTest.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,27 @@ public function testDeleteUserWithPlugin() {
342342
$this->pluginManager->expects($this->once())
343343
->method('deleteUser')
344344
->with('uid')
345-
->willReturn('result');
345+
->willReturn(true);
346+
347+
$this->config->expects($this->once())
348+
->method('getUserValue')
349+
->with('uid', 'user_ldap', 'isDeleted', 0)
350+
->willReturn(1);
351+
352+
$mapper = $this->createMock(UserMapping::class);
353+
$mapper->expects($this->once())
354+
->method('unmap')
355+
->with('uid');
356+
357+
$this->access->expects($this->atLeastOnce())
358+
->method('getUserMapper')
359+
->willReturn($mapper);
360+
361+
$this->userManager->expects($this->once())
362+
->method('invalidate')
363+
->with('uid');
346364

347-
$this->assertEquals($this->backend->deleteUser('uid'),'result');
365+
$this->assertEquals(true, $this->backend->deleteUser('uid'));
348366
}
349367

350368
/**

0 commit comments

Comments
 (0)