diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 17d6e4c923ee18a5a2d396e290e005d553c4a4e5..3dae3d799abae105ec1837d1708247dd2a381c47 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -8,6 +8,8 @@ namespace OCA\EcloudAccounts\Controller; use Exception; use OCA\EcloudAccounts\AppInfo\Application; +use OCA\EcloudAccounts\Exception\AddUsernameToCommonStoreException; +use OCA\EcloudAccounts\Exception\LDAPUserCreationException; use OCA\EcloudAccounts\Service\CaptchaService; use OCA\EcloudAccounts\Service\NewsLetterService; use OCA\EcloudAccounts\Service\UserService; @@ -156,11 +158,7 @@ class AccountController extends Controller { $this->session->remove(self::SESSION_USERNAME_CHECK); $this->session->remove(self::CAPTCHA_VERIFIED_CHECK); - try { - $this->userService->addUsernameToCommonDataStore($username); - } catch (Exception $e) { - $this->logger->logException($e, ['app' => Application::APP_ID]); - } + $this->userService->addUsernameToCommonDataStore($username); $response->setStatus(200); $response->setData(['success' => true]); @@ -168,6 +166,10 @@ class AccountController extends Controller { $this->logger->logException($e, ['app' => Application::APP_ID]); $response->setData(['message' => 'A server-side error occurred while processing your request! Please try again later.', 'success' => false]); $response->setStatus(500); + } catch (AddUsernameToCommonStoreException $e) { + $this->logger->logException($e, ['app' => Application::APP_ID]); + $response->setStatus(200); + $response->setData(['success' => true]); } catch (Exception $e) { $this->logger->logException($e, ['app' => Application::APP_ID]); $response->setData(['message' => 'An error occurred while creating your account!', 'success' => false]); diff --git a/lib/Exception/AddUsernameToCommonStoreException.php b/lib/Exception/AddUsernameToCommonStoreException.php new file mode 100644 index 0000000000000000000000000000000000000000..c7fa6da0b5b4d7dea382d82eebaf5c50d98a2be6 --- /dev/null +++ b/lib/Exception/AddUsernameToCommonStoreException.php @@ -0,0 +1,9 @@ +apiConfig['commonServicesURL']; $commonApiVersion = $this->apiConfig['commonApiVersion']; @@ -505,7 +516,7 @@ class UserService { $this->curl->post($url, $params, $headers); if ($this->curl->getLastStatusCode() !== 200) { - throw new Exception("Error adding username '$username' to common data store."); + throw new AddUsernameToCommonStoreException("Error adding username '$username' to common data store."); } } }