diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-01-22 21:47:25 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-01-26 11:20:58 +0100 |
commit | 70b19761aaef961efe90ef509fb0501afc6b538d (patch) | |
tree | 1edd39c6277dfd3d46fe7788e7f53240bf1075c1 /apps | |
parent | fe7e726ab228e6ddde7cf1442de9d0db193334a1 (diff) | |
download | nextcloud-server-70b19761aaef961efe90ef509fb0501afc6b538d.tar.gz nextcloud-server-70b19761aaef961efe90ef509fb0501afc6b538d.zip |
Provide list of editable fields via OCS API
Fixes #7983
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/provisioning_api/appinfo/routes.php | 1 | ||||
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/apps/provisioning_api/appinfo/routes.php b/apps/provisioning_api/appinfo/routes.php index c4932ebb28b..ea1a073f5e8 100644 --- a/apps/provisioning_api/appinfo/routes.php +++ b/apps/provisioning_api/appinfo/routes.php @@ -44,6 +44,7 @@ return [ ['root' => '/cloud', 'name' => 'Users#addUser', 'url' => '/users', 'verb' => 'POST'], ['root' => '/cloud', 'name' => 'Users#getUser', 'url' => '/users/{userId}', 'verb' => 'GET'], ['root' => '/cloud', 'name' => 'Users#getCurrentUser', 'url' => '/user', 'verb' => 'GET'], + ['root' => '/cloud', 'name' => 'Users#getEditableField', 'url' => '/user/fields', 'verb' => 'GET'], ['root' => '/cloud', 'name' => 'Users#editUser', 'url' => '/users/{userId}', 'verb' => 'PUT'], ['root' => '/cloud', 'name' => 'Users#deleteUser', 'url' => '/users/{userId}', 'verb' => 'DELETE'], ['root' => '/cloud', 'name' => 'Users#enableUser', 'url' => '/users/{userId}/enable', 'verb' => 'PUT'], diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 9098797f1ac..1c7522d4301 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -299,6 +299,38 @@ class UsersController extends OCSController { /** * @NoAdminRequired * @NoSubAdminRequired + */ + public function getEditableField() { + $permittedFields = []; + + // Editing self (display, email) + if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) { + $permittedFields[] = AccountManager::PROPERTY_DISPLAYNAME; + $permittedFields[] = AccountManager::PROPERTY_EMAIL; + } + + $permittedFields[] = 'password'; + if ($this->config->getSystemValue('force_language', false) === false) { + $permittedFields[] = 'language'; + } + + if ($this->appManager->isEnabledForUser('federatedfilesharing')) { + $federatedFileSharing = new \OCA\FederatedFileSharing\AppInfo\Application(); + $shareProvider = $federatedFileSharing->getFederatedShareProvider(); + if ($shareProvider->isLookupServerUploadEnabled()) { + $permittedFields[] = AccountManager::PROPERTY_PHONE; + $permittedFields[] = AccountManager::PROPERTY_ADDRESS; + $permittedFields[] = AccountManager::PROPERTY_WEBSITE; + $permittedFields[] = AccountManager::PROPERTY_TWITTER; + } + } + + return new DataResponse($permittedFields); + } + + /** + * @NoAdminRequired + * @NoSubAdminRequired * @PasswordConfirmationRequired * * edit users |