diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 82aa85071456260667c541d6d847b05355a3377b..4b1421d17f2ba05cf1c993969730716a12ceced2 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -11,6 +11,7 @@ use OCA\EcloudAccounts\AppInfo\Application; use OCA\EcloudAccounts\Exception\AddUsernameToCommonStoreException; use OCA\EcloudAccounts\Exception\BlacklistedEmailException; use OCA\EcloudAccounts\Exception\LDAPUserCreationException; +use OCA\EcloudAccounts\Exception\RecoveryEmailValidationException; use OCA\EcloudAccounts\Service\CaptchaService; use OCA\EcloudAccounts\Service\NewsLetterService; use OCA\EcloudAccounts\Service\UserService; @@ -168,7 +169,7 @@ 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 (BlacklistedEmailException | Error $e) { + } catch (BlacklistedEmailException | RecoveryEmailValidationException | Error $e) { $this->logger->logException($e, ['app' => Application::APP_ID]); $response->setData(['message' => $e->getMessage(), 'success' => false]); $response->setStatus(500); diff --git a/lib/Exception/RecoveryEmailValidationException.php b/lib/Exception/RecoveryEmailValidationException.php new file mode 100644 index 0000000000000000000000000000000000000000..528a3372909b74bf7bf0247e2c182e334e31078e --- /dev/null +++ b/lib/Exception/RecoveryEmailValidationException.php @@ -0,0 +1,9 @@ +isValidEmailFormat($recoveryEmail)) { - throw new Exception('Recovery email address has an incorrect format.'); + throw new RecoveryEmailValidationException('Recovery email address has an incorrect format.'); } if ($this->checkRecoveryEmailAvailable($recoveryEmail)) { - throw new Exception('Recovery email address is already taken.'); + throw new RecoveryEmailValidationException('Recovery email address is already taken.'); } if ($this->isRecoveryEmailDomainDisallowed($recoveryEmail)) { - throw new Exception('You cannot set an email address with a Murena domain as recovery email address.'); + throw new RecoveryEmailValidationException('You cannot set an email address with a Murena domain as recovery email address.'); } if ($this->blackListService->isBlacklistedEmail($recoveryEmail)) { throw new BlacklistedEmailException('The domain of this email address is blacklisted. Please provide another recovery address.');