From f10226fc6bd198d0e08b5c9f2a4f146873d750f2 Mon Sep 17 00:00:00 2001 From: "Gloire Mutaliko (Salva)" <86450367+GloireMutaliko21@users.noreply.github.com> Date: Thu, 18 Jul 2024 13:59:48 +0200 Subject: [PATCH] [Bug] Register | Tenant SMTP blocks new users to register (development environment) (#2753) * fix: error handling on user registration * refact: using if check for SMTP error handlers --- apps/web/app/api/auth/register/route.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/web/app/api/auth/register/route.ts b/apps/web/app/api/auth/register/route.ts index 658fefb2b..bad732db7 100644 --- a/apps/web/app/api/auth/register/route.ts +++ b/apps/web/app/api/auth/register/route.ts @@ -13,7 +13,7 @@ import { } from '@app/services/server/requests'; import { setAuthCookies } from '@app/helpers/cookies'; import { recaptchaVerification } from '@app/services/server/recaptcha'; -import { RECAPTCHA_SECRET_KEY, VERIFY_EMAIL_CALLBACK_PATH } from '@app/constants'; +import { RECAPTCHA_SECRET_KEY, SMTP_PASSWORD, SMTP_USERNAME, VERIFY_EMAIL_CALLBACK_PATH } from '@app/constants'; import { NextResponse } from 'next/server'; export async function POST(req: Request) { @@ -84,10 +84,12 @@ export async function POST(req: Request) { const { data: tenant } = await createTenantRequest(body.team, auth_token); // Create tenant SMTP - await createTenantSmtpRequest({ - access_token: auth_token, - tenantId: tenant.id - }); + if (SMTP_USERNAME && SMTP_PASSWORD) { + await createTenantSmtpRequest({ + access_token: auth_token, + tenantId: tenant.id + }); + } // Create user organization const { data: organization } = await createOrganizationRequest(