From c1e63bcbda5fb4606355320e717bd2b8f77b6f5e Mon Sep 17 00:00:00 2001 From: Sean Brydon Date: Thu, 14 Sep 2023 11:47:16 +0100 Subject: [PATCH] Throw error --- packages/features/auth/signup/handlers/calcomHandler.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/features/auth/signup/handlers/calcomHandler.ts b/packages/features/auth/signup/handlers/calcomHandler.ts index 2257136928..476557a754 100644 --- a/packages/features/auth/signup/handlers/calcomHandler.ts +++ b/packages/features/auth/signup/handlers/calcomHandler.ts @@ -6,6 +6,7 @@ import { hashPassword } from "@calcom/features/auth/lib/hashPassword"; import { sendEmailVerification } from "@calcom/features/auth/lib/verifyEmail"; import { WEBAPP_URL } from "@calcom/lib/constants"; import { getLocaleFromRequest } from "@calcom/lib/getLocaleFromRequest"; +import { HttpError } from "@calcom/lib/http-error"; import { createWebUser as syncServicesCreateWebUser } from "@calcom/lib/sync/SyncServiceManager"; import { closeComUpsertTeamUser } from "@calcom/lib/sync/SyncServiceManager"; import { validateUsername } from "@calcom/lib/validateUsername"; @@ -39,8 +40,10 @@ async function handler(req: RequestWithUsernameStatus, res: NextApiResponse) { // Validate the user if (!username) { - res.status(422).json({ message: "Invalid username" }); - return; + throw new HttpError({ + statusCode: 422, + message: "Invalid username", + }); } const email = _email.toLowerCase();