mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
feat: add ocs route to get apps enabled for current user
Signed-off-by: Jana Peper <jana.peper@nextcloud.com>
This commit is contained in:
parent
98871fe474
commit
50c9852e24
4 changed files with 18 additions and 2 deletions
|
|
@ -35,6 +35,7 @@ return [
|
|||
['root' => '/cloud', 'name' => 'Users#getCurrentUser', 'url' => '/user', 'verb' => 'GET'],
|
||||
['root' => '/cloud', 'name' => 'Users#getEditableFields', 'url' => '/user/fields', 'verb' => 'GET'],
|
||||
['root' => '/cloud', 'name' => 'Users#getEditableFieldsForUser', 'url' => '/user/fields/{userId}', 'verb' => 'GET'],
|
||||
['root' => '/cloud', 'name' => 'Users#getEnabledApps', 'url' => '/user/apps', 'verb' => 'GET'],
|
||||
['root' => '/cloud', 'name' => 'Users#editUser', 'url' => '/users/{userId}', 'verb' => 'PUT'],
|
||||
['root' => '/cloud', 'name' => 'Users#editUserMultiValue', 'url' => '/users/{userId}/{collectionName}', 'verb' => 'PUT', 'requirements' => ['collectionName' => '^(?!enable$|disable$)[a-zA-Z0-9_]*$']],
|
||||
['root' => '/cloud', 'name' => 'Users#wipeUserDevices', 'url' => '/users/{userId}/wipe', 'verb' => 'POST'],
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use OCA\Settings\Settings\Admin\Users;
|
|||
use OCP\Accounts\IAccountManager;
|
||||
use OCP\Accounts\IAccountProperty;
|
||||
use OCP\Accounts\PropertyDoesNotExistException;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
|
|
@ -79,6 +80,7 @@ class UsersController extends AUserDataOCSController {
|
|||
private KnownUserService $knownUserService,
|
||||
private IEventDispatcher $eventDispatcher,
|
||||
private IPhoneNumberUtil $phoneNumberUtil,
|
||||
private IAppManager $appManager,
|
||||
) {
|
||||
parent::__construct(
|
||||
$appName,
|
||||
|
|
@ -709,6 +711,19 @@ class UsersController extends AUserDataOCSController {
|
|||
return $this->getEditableFieldsForUser($currentLoggedInUser->getUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of enabled apps for the current user
|
||||
*
|
||||
* @return DataResponse<Http::STATUS_OK, array{apps: list<string>}, array{}>
|
||||
*
|
||||
* 200: Enabled apps returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getEnabledApps(): DataResponse {
|
||||
$currentLoggedInUser = $this->userSession->getUser();
|
||||
return new DataResponse(['apps' => $this->appManager->getEnabledAppsForUser($currentLoggedInUser)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ class AppManager implements IAppManager {
|
|||
* List all apps enabled for a user
|
||||
*
|
||||
* @param \OCP\IUser $user
|
||||
* @return string[]
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getEnabledAppsForUser(IUser $user) {
|
||||
$apps = $this->getEnabledAppsValues();
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ interface IAppManager {
|
|||
* List all apps enabled for a user
|
||||
*
|
||||
* @param \OCP\IUser $user
|
||||
* @return string[]
|
||||
* @return list<string>
|
||||
* @since 8.1.0
|
||||
*/
|
||||
public function getEnabledAppsForUser(IUser $user);
|
||||
|
|
|
|||
Loading…
Reference in a new issue