Skip to content

Commit 3c3d007

Browse files
authored
Merge pull request #8515 from nextcloud/13-8502
[stable13] Show hint in OCS API for user creation
2 parents 1eb8aee + 168f188 commit 3c3d007

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

apps/provisioning_api/lib/Controller/UsersController.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
namespace OCA\Provisioning_API\Controller;
3232

3333
use OC\Accounts\AccountManager;
34+
use OC\HintException;
3435
use OC\Settings\Mailer\NewUserMailHelper;
3536
use OC_Helper;
3637
use OCP\App\IAppManager;
@@ -187,15 +188,22 @@ public function addUser($userid, $password, $groups = null) {
187188

188189
try {
189190
$newUser = $this->userManager->createUser($userid, $password);
190-
$this->logger->info('Successful addUser call with userid: '.$userid, ['app' => 'ocs_api']);
191+
$this->logger->info('Successful addUser call with userid: ' . $userid, ['app' => 'ocs_api']);
191192

192193
if (is_array($groups)) {
193194
foreach ($groups as $group) {
194195
$this->groupManager->get($group)->addUser($newUser);
195-
$this->logger->info('Added userid '.$userid.' to group '.$group, ['app' => 'ocs_api']);
196+
$this->logger->info('Added userid ' . $userid . ' to group ' . $group, ['app' => 'ocs_api']);
196197
}
197198
}
198199
return new DataResponse();
200+
} catch (HintException $e ) {
201+
$this->logger->logException($e, [
202+
'message' => 'Failed addUser attempt with hint exception.',
203+
'level' => \OCP\Util::WARN,
204+
'app' => 'ocs_api',
205+
]);
206+
throw new OCSException($e->getHint(), 107);
199207
} catch (\Exception $e) {
200208
$this->logger->error('Failed addUser attempt with exception: '.$e->getMessage(), ['app' => 'ocs_api']);
201209
throw new OCSException('Bad request', 101);

0 commit comments

Comments
 (0)