diff --git a/packages/trpc/server/routers/loggedInViewer/addSecondaryEmail.handler.ts b/packages/trpc/server/routers/loggedInViewer/addSecondaryEmail.handler.ts index f03b2fc7ce..6a0218da1f 100644 --- a/packages/trpc/server/routers/loggedInViewer/addSecondaryEmail.handler.ts +++ b/packages/trpc/server/routers/loggedInViewer/addSecondaryEmail.handler.ts @@ -1,6 +1,7 @@ import type { GetServerSidePropsContext, NextApiResponse } from "next"; import { sendEmailVerification } from "@calcom/features/auth/lib/verifyEmail"; +import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError"; import { prisma } from "@calcom/prisma"; import type { TrpcSessionUser } from "@calcom/trpc/server/trpc"; @@ -19,6 +20,11 @@ type AddSecondaryEmailOptions = { export const addSecondaryEmailHandler = async ({ ctx, input }: AddSecondaryEmailOptions) => { const { user } = ctx; + await checkRateLimitAndThrowError({ + rateLimitingType: "core", + identifier: `addSecondaryEmail.${user.email}`, + }); + const existingPrimaryEmail = await prisma.user.findUnique({ where: { email: input.email, diff --git a/packages/trpc/server/routers/viewer/auth/resendVerifyEmail.handler.ts b/packages/trpc/server/routers/viewer/auth/resendVerifyEmail.handler.ts index bf0a2ed8a1..3c93c68792 100644 --- a/packages/trpc/server/routers/viewer/auth/resendVerifyEmail.handler.ts +++ b/packages/trpc/server/routers/viewer/auth/resendVerifyEmail.handler.ts @@ -1,8 +1,5 @@ -import type { NextApiRequest } from "next"; - import { sendEmailVerification } from "@calcom/features/auth/lib/verifyEmail"; import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError"; -import getIP from "@calcom/lib/getIP"; import logger from "@calcom/lib/logger"; import { prisma } from "@calcom/prisma"; import { TRPCError } from "@calcom/trpc/server"; @@ -23,7 +20,7 @@ const log = logger.getSubLogger({ prefix: [`[[Auth] `] }); export const resendVerifyEmail = async ({ input, ctx }: ResendEmailOptions) => { let emailToVerify = ctx.user.email; - const identifer = ctx.req ? getIP(ctx.req as NextApiRequest) : emailToVerify; + const identifer = emailToVerify; await checkRateLimitAndThrowError({ rateLimitingType: "core",