diff --git a/integrations/nextcloud/snappymail/lib/Controller/FetchController.php b/integrations/nextcloud/snappymail/lib/Controller/FetchController.php index af0dcd8fd..2b33ad945 100644 --- a/integrations/nextcloud/snappymail/lib/Controller/FetchController.php +++ b/integrations/nextcloud/snappymail/lib/Controller/FetchController.php @@ -119,12 +119,21 @@ class FetchController extends Controller { ]); } + // Logout as the credentials have changed + SnappyMailHelper::loadApp(); + \RainLoop\Api::Actions()->DoLogout(); + return new JSONResponse([ 'status' => 'success', 'Message' => $this->l->t('Saved successfully'), 'Email' => $sEmail ]); } catch (Exception $e) { + // Logout as the credentials might have changed, as exception could be in one attribute + // TODO: Handle both exceptions separately? + SnappyMailHelper::loadApp(); + \RainLoop\Api::Actions()->DoLogout(); + return new JSONResponse([ 'status' => 'error', 'Message' => $e->getMessage()