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);
|
ensurePostMethod(req);
|
||||||
throwIfSignupIsDisabled();
|
throwIfSignupIsDisabled();
|
||||||
const { email, password, language, token, username } = parseSignupData(req.body);
|
const { email, password, language, token, username } = parseSignupData(req.body);
|
||||||
await findExistingUser(username, email);
|
|
||||||
const hashedPassword = await hashPassword(password);
|
const hashedPassword = await hashPassword(password);
|
||||||
|
|
||||||
const customer = await createStripeCustomer({
|
const customer = await createStripeCustomer({
|
||||||
|
@ -47,6 +46,8 @@ async function handler(req: RequestWithUsernameStatus, res: NextApiResponse) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
await findExistingUser(username, email);
|
||||||
|
|
||||||
// Create the user
|
// Create the user
|
||||||
const user = await createUser({
|
const user = await createUser({
|
||||||
username,
|
username,
|
||||||
|
@ -107,7 +108,6 @@ async function handler(req: RequestWithUsernameStatus, res: NextApiResponse) {
|
||||||
|
|
||||||
return res.status(201).json({ message: "Created user" });
|
return res.status(201).json({ message: "Created user" });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
|
||||||
if (e instanceof HttpError) {
|
if (e instanceof HttpError) {
|
||||||
return res.status(e.statusCode).json({ message: e.message });
|
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 notEmpty from "../../../apps/website/lib/utils/notEmpty";
|
||||||
import { wordlist } from "../../../apps/website/lib/utils/wordlist/wordlist";
|
import { wordlist } from "../../../apps/website/lib/utils/wordlist/wordlist";
|
||||||
|
import { IS_CALCOM } from "../constants";
|
||||||
|
|
||||||
export type RequestWithUsernameStatus = NextApiRequest & {
|
export type RequestWithUsernameStatus = NextApiRequest & {
|
||||||
usernameStatus: {
|
usernameStatus: {
|
||||||
|
@ -47,6 +48,20 @@ const usernameHandler =
|
||||||
(handler: CustomNextApiHandler) =>
|
(handler: CustomNextApiHandler) =>
|
||||||
async (req: RequestWithUsernameStatus, res: NextApiResponse): Promise<void> => {
|
async (req: RequestWithUsernameStatus, res: NextApiResponse): Promise<void> => {
|
||||||
const username = slugify(req.body.username);
|
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);
|
const check = await usernameCheck(username);
|
||||||
|
|
||||||
req.usernameStatus = {
|
req.usernameStatus = {
|
||||||
|
|
Loading…
Reference in New Issue