fix: identifer (#12426)
Co-authored-by: Udit Takkar <udit222001@gmail.com>
This commit is contained in:
parent
27d969f995
commit
0c3321a35e
|
@ -71,7 +71,7 @@ export const authRouter = router({
|
|||
});
|
||||
}),
|
||||
|
||||
sendVerifyEmailCode: publicProcedure.input(ZSendVerifyEmailCodeSchema).mutation(async ({ input }) => {
|
||||
sendVerifyEmailCode: publicProcedure.input(ZSendVerifyEmailCodeSchema).mutation(async ({ input, ctx }) => {
|
||||
if (!UNSTABLE_HANDLER_CACHE.sendVerifyEmailCode) {
|
||||
UNSTABLE_HANDLER_CACHE.sendVerifyEmailCode = await import("./sendVerifyEmailCode.handler").then(
|
||||
(mod) => mod.sendVerifyEmailCodeHandler
|
||||
|
@ -85,6 +85,7 @@ export const authRouter = router({
|
|||
|
||||
return UNSTABLE_HANDLER_CACHE.sendVerifyEmailCode({
|
||||
input,
|
||||
req: ctx.req,
|
||||
});
|
||||
}),
|
||||
|
||||
|
|
|
@ -1,12 +1,25 @@
|
|||
import { sendEmailVerificationByCode } from "@calcom/features/auth/lib/verifyEmail";
|
||||
import type { NextApiRequest } from "next";
|
||||
|
||||
import { sendEmailVerificationByCode } from "@calcom/features/auth/lib/verifyEmail";
|
||||
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
|
||||
import getIP from "@calcom/lib/getIP";
|
||||
|
||||
import type { TRPCContext } from "../../../createContext";
|
||||
import type { TSendVerifyEmailCodeSchema } from "./sendVerifyEmailCode.schema";
|
||||
|
||||
type SendVerifyEmailCode = {
|
||||
input: TSendVerifyEmailCodeSchema;
|
||||
req: TRPCContext["req"] | undefined;
|
||||
};
|
||||
|
||||
export const sendVerifyEmailCodeHandler = async ({ input }: SendVerifyEmailCode) => {
|
||||
export const sendVerifyEmailCodeHandler = async ({ input, req }: SendVerifyEmailCode) => {
|
||||
const identifer = req ? getIP(req as NextApiRequest) : input.email;
|
||||
|
||||
await checkRateLimitAndThrowError({
|
||||
rateLimitingType: "core",
|
||||
identifier: `emailVerifyByCode.${identifer}`,
|
||||
});
|
||||
|
||||
const email = await sendEmailVerificationByCode({
|
||||
email: input.email,
|
||||
username: input.username,
|
||||
|
|
Loading…
Reference in New Issue
Block a user