Merge pull request #16112 from nextcloud/backport/16101/stable16

[stable16] invalidates user when plugin reported deletion success
This commit is contained in:
Roeland Jago Douma 2019-06-27 16:09:58 +02:00 committed by GitHub
commit 66dc4c9c72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 7 deletions

View File

@ -1133,9 +1133,18 @@ 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);
$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;
}
throw new \Exception('Could not create group in LDAP backend.');

View File

@ -382,18 +382,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);

View File

@ -342,9 +342,27 @@ class User_LDAPTest extends TestCase {
$this->pluginManager->expects($this->once())
->method('deleteUser')
->with('uid')
->willReturn('result');
->willReturn(true);
$this->assertEquals($this->backend->deleteUser('uid'),'result');
$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(true, $this->backend->deleteUser('uid'));
}
/**