Files
calendar/packages/trpc/server/routers/viewer/auth/sendVerifyEmailCode.handler.ts
T
Rajiv SahalGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
5d65a0f091 fix: hide cal branding for orgs/teams (#27643)
* fix: hide branding for teams

* fix: remove unused organizationId and username fields from profiles select

Addresses Cubic AI review feedback (confidence 9/10) to select only
the profile fields that are actually used. The organizationId and
username fields were fetched but never referenced in this function.

Co-Authored-By: unknown <>

* fix: unit tests

* fix: add prisma named export to test mock

Co-Authored-By: rajiv@cal.com <sahalrajiv6900@gmail.com>

* Add tests: packages/features/profile/lib/hideBranding.test.ts

Generated by Paragon from proposal for PR #27643

* chore: implement cubic feedback

* fix: merge conflicts

* fix: unit tests

* fixup

* refactor: implement DI pattern for event type service

* fix: atoms build

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-02-25 20:53:01 +09:00

46 lines
1.6 KiB
TypeScript

import { sendEmailVerificationByCode } from "@calcom/features/auth/lib/verifyEmail";
import { getEventTypeService } from "@calcom/features/eventtypes/di/EventTypeService.container";
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
import getIP from "@calcom/lib/getIP";
import { hashEmail, piiHasher } from "@calcom/lib/server/PiiHasher";
import type { NextApiRequest } from "next";
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 identifier = req ? piiHasher.hash(getIP(req as NextApiRequest)) : hashEmail(input.email);
return sendVerifyEmailCode({ input, identifier });
};
export const sendVerifyEmailCode = async ({
input,
identifier,
}: {
input: TSendVerifyEmailCodeSchema;
identifier: string;
}) => {
await checkRateLimitAndThrowError({
rateLimitingType: "core",
identifier: `sendVerifyEmailCode:${identifier}`,
});
let hideBranding = false;
if (input.eventTypeId) {
const eventTypeService = getEventTypeService();
hideBranding = await eventTypeService.shouldHideBrandingForEventType(input.eventTypeId);
}
return await sendEmailVerificationByCode({
email: input.email,
username: input.username,
language: input.language,
isVerifyingEmail: input.isVerifyingEmail,
hideBranding,
});
};