diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-02-22 14:16:49 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-02-22 14:16:49 +0100 |
commit | 9aaf1c2a062a543a5ed22ec3346b71f312d6d4ff (patch) | |
tree | 7dbf6e43b74cabe31a5fde40b3cc4c2c0e21d5fe /apps/provisioning_api | |
parent | c2c2c06546801d956778f5ab87e9042d45b40dc4 (diff) | |
download | nextcloud-server-9aaf1c2a062a543a5ed22ec3346b71f312d6d4ff.tar.gz nextcloud-server-9aaf1c2a062a543a5ed22ec3346b71f312d6d4ff.zip |
Show hint in OCS API for user creation
* adds a 107 error code together with the hint of the exception
* logs the exception as warning
* fixes #7946
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 99f1a0ddd57..402381ab58a 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -31,6 +31,7 @@ namespace OCA\Provisioning_API\Controller; use OC\Accounts\AccountManager; +use OC\HintException; use OC\Settings\Mailer\NewUserMailHelper; use OC_Helper; use OCA\Provisioning_API\FederatedFileSharingFactory; @@ -193,15 +194,22 @@ class UsersController extends OCSController { try { $newUser = $this->userManager->createUser($userid, $password); - $this->logger->info('Successful addUser call with userid: '.$userid, ['app' => 'ocs_api']); + $this->logger->info('Successful addUser call with userid: ' . $userid, ['app' => 'ocs_api']); if (is_array($groups)) { foreach ($groups as $group) { $this->groupManager->get($group)->addUser($newUser); - $this->logger->info('Added userid '.$userid.' to group '.$group, ['app' => 'ocs_api']); + $this->logger->info('Added userid ' . $userid . ' to group ' . $group, ['app' => 'ocs_api']); } } return new DataResponse(); + } catch (HintException $e ) { + $this->logger->logException($e, [ + 'message' => 'Failed addUser attempt with hint exception.', + 'level' => \OCP\Util::WARN, + 'app' => 'ocs_api', + ]); + throw new OCSException($e->getHint(), 107); } catch (\Exception $e) { $this->logger->logException($e, [ 'message' => 'Failed addUser attempt with exception.', |