From 7f65c9acc8bae0044099909154a225fcd31eb0f3 Mon Sep 17 00:00:00 2001 From: Roberto Guido Date: Wed, 1 Jul 2026 00:53:58 +0200 Subject: [PATCH] fix: while creating a new account, check for his existance Signed-off-by: Roberto Guido --- lib/Controller/AccountsController.php | 6 ++++++ src/components/AccountForm.vue | 2 ++ 2 files changed, 8 insertions(+) diff --git a/lib/Controller/AccountsController.php b/lib/Controller/AccountsController.php index 81cb19067f..393da826bf 100644 --- a/lib/Controller/AccountsController.php +++ b/lib/Controller/AccountsController.php @@ -338,6 +338,12 @@ public function create(string $accountName, $this->logger->info('Creating account disabled by admin.'); return MailJsonResponse::error('Could not create account'); } + if (empty($this->accountService->findByUserIdAndAddress($this->userId, $emailAddress)) === false) { + $this->logger->info('Trying to create already existing account.'); + return MailJsonResponse::fail([ + 'error' => 'ACCOUNT_EXISTS', + ]); + } if (!$this->hostValidator->isValid($imapHost)) { $this->logger->debug('Prevented access to invalid IMAP host', [ 'host' => $imapHost, diff --git a/src/components/AccountForm.vue b/src/components/AccountForm.vue index 217a214c1f..ec5b9c566d 100644 --- a/src/components/AccountForm.vue +++ b/src/components/AccountForm.vue @@ -692,6 +692,8 @@ export default { } else if (error.data.service === 'SMTP') { this.feedback = t('mail', 'SMTP server is not reachable') } + } else if (error.data?.error === 'ACCOUNT_EXISTS') { + this.feedback = t('mail', 'Account already exists') } else if (error.data?.error === 'AUTHENTICATION_WRONG_PASSWORD') { if (error.data.service === 'IMAP') { this.feedback = t('mail', 'IMAP username or password is wrong')