From ec1c4fd5c3c729c4ecb8cab65344927aa735d69c Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 27 May 2022 05:45:38 +0000 Subject: [PATCH] Bypass SMTP host check for admins adding team members Since no email is sent when adding team members for admins, there shouldn't be any need to check the SMTP host. --- app/controllers/api/teams.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 7244c4e240..03b4c41055 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -295,13 +295,13 @@ App::post('/v1/teams/:teamId/memberships') ->inject('events') ->action(function (string $teamId, string $email, array $roles, string $url, string $name, Response $response, Document $project, Document $user, Database $dbForProject, Locale $locale, EventAudit $audits, Mail $mails, Event $events) { - if (empty(App::getEnv('_APP_SMTP_HOST'))) { - throw new Exception('SMTP Disabled', 503, Exception::GENERAL_SMTP_DISABLED); - } - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); $isAppUser = Auth::isAppUser(Authorization::getRoles()); + if (!$isPrivilegedUser && !$isAppUser && empty(App::getEnv('_APP_SMTP_HOST'))) { + throw new Exception('SMTP Disabled', 503, Exception::GENERAL_SMTP_DISABLED); + } + $email = \strtolower($email); $name = (empty($name)) ? $email : $name; $team = $dbForProject->getDocument('teams', $teamId);