diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-09-01 17:07:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-01 17:07:13 +0200 |
commit | 253c0641b138d6eeb4397f82ba3738d9adb132a2 (patch) | |
tree | 43790db6d0806c3b34c7d332d14d4bc79d0c6d8f /apps | |
parent | 12e7f414f783acc9a30b7000a09b68a214077f04 (diff) | |
parent | d59585974e2f3f51598da31f6e1dd0684affa77b (diff) | |
download | nextcloud-server-253c0641b138d6eeb4397f82ba3738d9adb132a2.tar.gz nextcloud-server-253c0641b138d6eeb4397f82ba3738d9adb132a2.zip |
Merge pull request #33625 from nextcloud/fix/33572/add-user
Fix creation of new user and display the correct error message
Diffstat (limited to 'apps')
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 15 |
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: |