Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable15] invalidates user when plugin reported deletion success #16113

Merged
merged 2 commits into from
Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions apps/user_ldap/lib/Group_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -1133,8 +1133,17 @@ public function createGroup($gid) {
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;
}
Expand Down
9 changes: 6 additions & 3 deletions apps/user_ldap/lib/User_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,21 @@ public function userExists($uid) {
*/
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);
Expand Down
22 changes: 20 additions & 2 deletions apps/user_ldap/tests/User_LDAPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,27 @@ public function testDeleteUserWithPlugin() {
$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'));
}

/**
Expand Down