|
31 | 31 | namespace OCA\Provisioning_API\Controller; |
32 | 32 |
|
33 | 33 | use OC\Accounts\AccountManager; |
| 34 | +use OC\HintException; |
34 | 35 | use OC\Settings\Mailer\NewUserMailHelper; |
35 | 36 | use OC_Helper; |
36 | 37 | use OCP\App\IAppManager; |
@@ -187,15 +188,22 @@ public function addUser($userid, $password, $groups = null) { |
187 | 188 |
|
188 | 189 | try { |
189 | 190 | $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']); |
191 | 192 |
|
192 | 193 | if (is_array($groups)) { |
193 | 194 | foreach ($groups as $group) { |
194 | 195 | $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']); |
196 | 197 | } |
197 | 198 | } |
198 | 199 | 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); |
199 | 207 | } catch (\Exception $e) { |
200 | 208 | $this->logger->error('Failed addUser attempt with exception: '.$e->getMessage(), ['app' => 'ocs_api']); |
201 | 209 | throw new OCSException('Bad request', 101); |
|
0 commit comments