diff --git a/apps/web/pages/api/auth/signup.ts b/apps/web/pages/api/auth/signup.ts index cba4a8f44a..c70109dc43 100644 --- a/apps/web/pages/api/auth/signup.ts +++ b/apps/web/pages/api/auth/signup.ts @@ -33,7 +33,6 @@ async function handler(req: RequestWithUsernameStatus, res: NextApiResponse) { ensurePostMethod(req); throwIfSignupIsDisabled(); const { email, password, language, token, username } = parseSignupData(req.body); - await findExistingUser(username, email); const hashedPassword = await hashPassword(password); const customer = await createStripeCustomer({ @@ -47,6 +46,8 @@ async function handler(req: RequestWithUsernameStatus, res: NextApiResponse) { }); if (!token) { + await findExistingUser(username, email); + // Create the user const user = await createUser({ username, @@ -107,7 +108,6 @@ async function handler(req: RequestWithUsernameStatus, res: NextApiResponse) { return res.status(201).json({ message: "Created user" }); } catch (e) { - console.log(e); if (e instanceof HttpError) { return res.status(e.statusCode).json({ message: e.message }); } diff --git a/packages/lib/server/username.ts b/packages/lib/server/username.ts index 60c9d548e6..623527b5d9 100644 --- a/packages/lib/server/username.ts +++ b/packages/lib/server/username.ts @@ -5,6 +5,7 @@ import prisma from "@calcom/prisma"; import notEmpty from "../../../apps/website/lib/utils/notEmpty"; import { wordlist } from "../../../apps/website/lib/utils/wordlist/wordlist"; +import { IS_CALCOM } from "../constants"; export type RequestWithUsernameStatus = NextApiRequest & { usernameStatus: { @@ -47,6 +48,20 @@ const usernameHandler = (handler: CustomNextApiHandler) => async (req: RequestWithUsernameStatus, res: NextApiResponse): Promise => { const username = slugify(req.body.username); + // If we're not in Calcom, we don't need to check for premium usernames + if (!IS_CALCOM) { + req.usernameStatus = { + statusCode: 200, + requestedUserName: username, + json: { + available: true, + premium: false, + message: "Username is available", + }, + }; + return handler(req, res); + } + const check = await usernameCheck(username); req.usernameStatus = {