Add method to list disabled users to IProvideEnabledStateBackend

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2023-06-29 16:15:12 +02:00
parent 1603cdc8d2
commit 189ccc2d72
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A
3 changed files with 25 additions and 0 deletions

View file

@ -681,4 +681,8 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I
$setDatabaseValue($enabled);
return $enabled;
}
public function getDisabledUserList(int $offset = 0, ?int $limit = null): array {
throw new \Exception('This is implemented directly in User_Proxy');
}
}

View file

@ -32,6 +32,7 @@
namespace OCA\User_LDAP;
use OCA\User_LDAP\User\DeletedUsersIndex;
use OCA\User_LDAP\User\OfflineUser;
use OCA\User_LDAP\User\User;
use OCP\IConfig;
use OCP\IUserBackend;
@ -461,4 +462,15 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP
public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): bool {
return $this->handleRequest($uid, 'setUserEnabled', [$uid, $enabled, $queryDatabaseValue, $setDatabaseValue]);
}
public function getDisabledUserList(int $offset = 0, ?int $limit = null): array {
return array_map(
fn (OfflineUser $user) => $user->getOCName(),
array_slice(
$this->deletedUsersIndex->getUsers(),
$offset,
$limit
)
);
}
}

View file

@ -44,4 +44,13 @@ interface IProvideEnabledStateBackend {
* @param callable(bool):void $setDatabaseValue A callable to set the enabled state in the database.
*/
public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): bool;
/**
* Get the list of disabled users, to merge with the ones disabled in database
*
* @since 28.0.0
*
* @return string[]
*/
public function getDisabledUserList(int $offset = 0, ?int $limit = null): array;
}