Return defaullt username status if not on calcom
parent
699db2f649
commit
e58f945915
|
@ -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 });
|
||||
}
|
||||
|
|
|
@ -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<void> => {
|
||||
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 = {
|
||||
|
|
Loading…
Reference in New Issue