* fix: RateLimit verify email * update * client chnages * type error * fix * add test * Update event-types.e2e.ts * minor update * Update event-types.e2e.ts * fix test * handle it in api v2
20 lines
535 B
TypeScript
20 lines
535 B
TypeScript
import type { ZVerifyCodeInputSchema } from "@calcom/prisma/zod-utils";
|
|
|
|
import { TRPCError } from "@trpc/server";
|
|
|
|
import { verifyCodeUnAuthenticated } from "./util";
|
|
|
|
type VerifyTokenOptions = {
|
|
input: ZVerifyCodeInputSchema;
|
|
};
|
|
|
|
export const verifyCodeUnAuthenticatedHandler = async ({ input }: VerifyTokenOptions) => {
|
|
const { email, code } = input;
|
|
try {
|
|
await verifyCodeUnAuthenticated(email, code);
|
|
return true;
|
|
} catch (error) {
|
|
throw new TRPCError({ code: "BAD_REQUEST", message: "invalid_code" });
|
|
}
|
|
};
|