Skip to content
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
1 change: 1 addition & 0 deletions apps/provisioning_api/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
['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'],
Expand Down
15 changes: 15 additions & 0 deletions apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;
Expand Down Expand Up @@ -79,6 +80,7 @@ public function __construct(
private KnownUserService $knownUserService,
private IEventDispatcher $eventDispatcher,
private IPhoneNumberUtil $phoneNumberUtil,
private IAppManager $appManager,
) {
parent::__construct(
$appName,
Expand Down Expand Up @@ -709,6 +711,19 @@ public function getEditableFields(): DataResponse {
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
*
Expand Down
72 changes: 72 additions & 0 deletions apps/provisioning_api/openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -3573,6 +3573,78 @@
}
}
},
"/ocs/v2.php/cloud/user/apps": {
"get": {
"operationId": "users-get-enabled-apps",
"summary": "Get a list of enabled apps for the current user",
"tags": [
"users"
],
"security": [
{
"bearer_auth": []
},
{
"basic_auth": []
}
],
"parameters": [
{
"name": "OCS-APIRequest",
"in": "header",
"description": "Required to be true for the API request to pass",
"required": true,
"schema": {
"type": "boolean",
"default": true
}
}
],
"responses": {
"200": {
"description": "Enabled apps returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"type": "object",
"required": [
"apps"
],
"properties": {
"apps": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"/ocs/v2.php/cloud/users/{userId}/{collectionName}": {
"put": {
"operationId": "users-edit-user-multi-value",
Expand Down
72 changes: 72 additions & 0 deletions apps/provisioning_api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,78 @@
}
}
},
"/ocs/v2.php/cloud/user/apps": {
"get": {
"operationId": "users-get-enabled-apps",
"summary": "Get a list of enabled apps for the current user",
"tags": [
"users"
],
"security": [
{
"bearer_auth": []
},
{
"basic_auth": []
}
],
"parameters": [
{
"name": "OCS-APIRequest",
"in": "header",
"description": "Required to be true for the API request to pass",
"required": true,
"schema": {
"type": "boolean",
"default": true
}
}
],
"responses": {
"200": {
"description": "Enabled apps returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"type": "object",
"required": [
"apps"
],
"properties": {
"apps": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"/ocs/v2.php/cloud/users/{userId}/{collectionName}": {
"put": {
"operationId": "users-edit-user-multi-value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use OCP\Accounts\IAccountManager;
use OCP\Accounts\IAccountProperty;
use OCP\Accounts\IAccountPropertyCollection;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\EventDispatcher\IEventDispatcher;
Expand Down Expand Up @@ -64,6 +65,7 @@ class UsersControllerTest extends TestCase {
private IEventDispatcher&MockObject $eventDispatcher;
private IRootFolder $rootFolder;
private IPhoneNumberUtil $phoneNumberUtil;
private IAppManager $appManager;

protected function setUp(): void {
parent::setUp();
Expand All @@ -84,6 +86,7 @@ protected function setUp(): void {
$this->knownUserService = $this->createMock(KnownUserService::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->phoneNumberUtil = new PhoneNumberUtil();
$this->appManager = $this->createMock(IAppManager::class);
$this->rootFolder = $this->createMock(IRootFolder::class);

$l10n = $this->createMock(IL10N::class);
Expand All @@ -110,6 +113,7 @@ protected function setUp(): void {
$this->knownUserService,
$this->eventDispatcher,
$this->phoneNumberUtil,
$this->appManager,
])
->onlyMethods(['fillStorageInfo'])
->getMock();
Expand Down Expand Up @@ -501,6 +505,7 @@ public function testAddUserSuccessfulWithDisplayName(): void {
$this->knownUserService,
$this->eventDispatcher,
$this->phoneNumberUtil,
$this->appManager,
])
->onlyMethods(['editUser'])
->getMock();
Expand Down Expand Up @@ -3796,6 +3801,7 @@ public function testGetCurrentUserLoggedIn(): void {
$this->knownUserService,
$this->eventDispatcher,
$this->phoneNumberUtil,
$this->appManager,
])
->onlyMethods(['getUserData'])
->getMock();
Expand Down Expand Up @@ -3887,6 +3893,7 @@ public function testGetUser(): void {
$this->knownUserService,
$this->eventDispatcher,
$this->phoneNumberUtil,
$this->appManager,
])
->onlyMethods(['getUserData'])
->getMock();
Expand Down
2 changes: 1 addition & 1 deletion lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function getAllAppsInAppsFolders(): array {
* List all apps enabled for a user
*
* @param \OCP\IUser $user
* @return string[]
* @return list<string>
*/
public function getEnabledAppsForUser(IUser $user) {
$apps = $this->getEnabledAppsValues();
Expand Down
2 changes: 1 addition & 1 deletion lib/public/App/IAppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function getAppWebPath(string $appId): string;
* 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);
Expand Down
72 changes: 72 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -25983,6 +25983,78 @@
}
}
},
"/ocs/v2.php/cloud/user/apps": {
"get": {
"operationId": "provisioning_api-users-get-enabled-apps",
"summary": "Get a list of enabled apps for the current user",
"tags": [
"provisioning_api/users"
],
"security": [
{
"bearer_auth": []
},
{
"basic_auth": []
}
],
"parameters": [
{
"name": "OCS-APIRequest",
"in": "header",
"description": "Required to be true for the API request to pass",
"required": true,
"schema": {
"type": "boolean",
"default": true
}
}
],
"responses": {
"200": {
"description": "Enabled apps returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"type": "object",
"required": [
"apps"
],
"properties": {
"apps": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"/ocs/v2.php/cloud/users/{userId}/{collectionName}": {
"put": {
"operationId": "provisioning_api-users-edit-user-multi-value",
Expand Down
Loading