aboutsummaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/lib/Controller/UsersController.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/provisioning_api/lib/Controller/UsersController.php')
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 51b18306b51..1d1d0e8d2f9 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -542,10 +542,16 @@ class UsersController extends AUserDataOCSController {
throw new OCSException($this->l10n->t('Required email address was not provided'), 110);
}
+ // Create the user
try {
$newUser = $this->userManager->createUser($userid, $password);
- $this->logger->info('Successful addUser call with userid: ' . $userid, ['app' => 'ocs_api']);
+ if (!$newUser instanceof IUser) {
+ // If the user is not an instance of IUser, it means the user creation failed
+ $this->logger->error('Failed addUser attempt: User creation failed.', ['app' => 'ocs_api']);
+ throw new OCSException($this->l10n->t('User creation failed'), 111);
+ }
+ $this->logger->info('Successful addUser call with userid: ' . $userid, ['app' => 'ocs_api']);
foreach ($groups as $group) {
$this->groupManager->get($group)->addUser($newUser);
$this->logger->info('Added userid ' . $userid . ' to group ' . $group, ['app' => 'ocs_api']);