* feat: Workflow — Send Email to Specific Email * disable button when verifyEmail pending * add verified emails table and routes * fix: include teamId in verifyEmailCode * fix: include email address in activate handler * fix: check team before adding email * feat: check verified email, add to team if only users * remove logs * fix: if statement Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> * change email to verify your email * fix: show error if saving unverified email * fix: show email in subject * verify email when editing steps * remove double calls from same block * verify email when creating new step --------- Co-authored-by: v0ltZzie <161201747+v0ltZzie@users.noreply.github.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
32 lines
1001 B
TypeScript
32 lines
1001 B
TypeScript
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, 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,
|
|
language: input.language,
|
|
isVerifyingEmail: input.isVerifyingEmail,
|
|
});
|
|
|
|
return email;
|
|
};
|