aboutsummaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/lib
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2022-08-19 20:02:57 +0000
committerChristopher Ng <chrng8@gmail.com>2022-08-22 19:13:11 +0000
commitd59585974e2f3f51598da31f6e1dd0684affa77b (patch)
tree13cdd86687f7aba4f4c65b81d81b06b2ba982c7f /apps/provisioning_api/lib
parent2576609aac3555da0926c27b879df610a8b0f43c (diff)
downloadnextcloud-server-d59585974e2f3f51598da31f6e1dd0684affa77b.tar.gz
nextcloud-server-d59585974e2f3f51598da31f6e1dd0684affa77b.zip
Fix creation of new user and display the correct error message
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/provisioning_api/lib')
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 839ac404c94..37bbdc9e1c4 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -426,7 +426,14 @@ class UsersController extends AUserData {
}
if ($displayName !== '') {
- $this->editUser($userid, self::USER_FIELD_DISPLAYNAME, $displayName);
+ try {
+ $this->editUser($userid, self::USER_FIELD_DISPLAYNAME, $displayName);
+ } catch (OCSException $e) {
+ if ($newUser instanceof IUser) {
+ $newUser->delete();
+ }
+ throw $e;
+ }
}
if ($quota !== '') {
@@ -837,8 +844,10 @@ class UsersController extends AUserData {
switch ($key) {
case self::USER_FIELD_DISPLAYNAME:
case IAccountManager::PROPERTY_DISPLAYNAME:
- if (!$targetUser->setDisplayName($value)) {
- throw new OCSException('Invalid displayname', 102);
+ try {
+ $targetUser->setDisplayName($value);
+ } catch (InvalidArgumentException $e) {
+ throw new OCSException($e->getMessage(), 101);
}
break;
case self::USER_FIELD_QUOTA: