chore: Skipping totp code for org dev (#10403)

This commit is contained in:
Leo Giovanetti
2023-07-26 18:15:37 +02:00
committed by GitHub
parent 83d98a1ac4
commit dae4627ada
3 changed files with 8 additions and 3 deletions
+2
View File
@@ -34,10 +34,12 @@ export const IS_CALCOM =
WEBAPP_URL &&
(new URL(WEBAPP_URL).hostname.endsWith("cal.com") ||
new URL(WEBAPP_URL).hostname.endsWith("cal.dev") ||
new URL(WEBAPP_URL).hostname.endsWith("cal.qa") ||
new URL(WEBAPP_URL).hostname.endsWith("cal-staging.com"));
export const CONSOLE_URL =
new URL(WEBAPP_URL).hostname.endsWith(".cal.dev") ||
new URL(WEBAPP_URL).hostname.endsWith(".cal.qa") ||
new URL(WEBAPP_URL).hostname.endsWith(".cal-staging.com") ||
process.env.NODE_ENV !== "production"
? `https://console.cal.dev`
@@ -5,7 +5,7 @@ import { sendOrganizationEmailVerification } from "@calcom/emails";
import { hashPassword } from "@calcom/features/auth/lib/hashPassword";
import { subdomainSuffix } from "@calcom/features/ee/organizations/lib/orgDomains";
import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "@calcom/lib/availability";
import { IS_PRODUCTION, IS_TEAM_BILLING_ENABLED, RESERVED_SUBDOMAINS } from "@calcom/lib/constants";
import { IS_CALCOM, IS_TEAM_BILLING_ENABLED, RESERVED_SUBDOMAINS } from "@calcom/lib/constants";
import { getTranslation } from "@calcom/lib/server/i18n";
import { prisma } from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums";
@@ -82,6 +82,8 @@ export const createHandler = async ({ input, ctx }: CreateOptions) => {
const availability = getAvailabilityFromSchedule(DEFAULT_SCHEDULE);
if (check === false) {
if (IS_CALCOM) await vercelCreateDomain(slug);
const createOwnerOrg = await prisma.user.create({
data: {
username: adminUsername,
@@ -118,8 +120,6 @@ export const createHandler = async ({ input, ctx }: CreateOptions) => {
},
});
if (IS_PRODUCTION) await vercelCreateDomain(slug);
await prisma.membership.create({
data: {
userId: createOwnerOrg.id,
@@ -1,6 +1,7 @@
import { createHash } from "crypto";
import { totp } from "otplib";
import { IS_PRODUCTION } from "@calcom/lib/constants";
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
import { TRPCError } from "@trpc/server";
@@ -20,6 +21,8 @@ export const verifyCodeHandler = async ({ ctx, input }: VerifyCodeOptions) => {
if (!user || !email || !code) throw new TRPCError({ code: "BAD_REQUEST" });
if (!IS_PRODUCTION) return true;
const secret = createHash("md5")
.update(email + process.env.CALENDSO_ENCRYPTION_KEY)
.digest("hex");