feat: email confirmation on change (#13443)
* feat:show old and new email in confirmation dialog * fix: update i18n * chore: update styles * wip: change email upon verification * fix: email being changed w/o need to logout * chore: tidy up - remove update sessison (WIP) will try do this serverside * wip: try new approach of serverside call to nextjs then client update * fix: tests * fix: update without logout * i18n: use i18n in toast * fix: locale ready toast * fix: restore email api template * fix: revert changes from wrong branch * fix: restore yarn.lock * feat: happy e2e path * fix: verification disabled e2e tests * fix:move toast * chore: cleanup early return * fix: await input selector * Update apps/web/pages/auth/verify-email-change.tsx * fix: feedback * fix: update the way we update session * fix: reset password -> email verified * fix: email change toast failure * tests: add tests for error path --------- Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
13 files changed
+619
-20
No files matched your search
@@ -27,6 +27,8 @@ import AttendeeWasRequestedToRescheduleEmail from "./templates/attendee-was-requ
|
||||
import BookingRedirectEmailNotification from "./templates/booking-redirect-notification";
|
||||
import type { IBookingRedirect } from "./templates/booking-redirect-notification";
|
||||
import BrokenIntegrationEmail from "./templates/broken-integration-email";
|
||||
import type { ChangeOfEmailVerifyLink } from "./templates/change-account-email-verify";
|
||||
import ChangeOfEmailVerifyEmail from "./templates/change-account-email-verify";
|
||||
import DisabledAppEmail from "./templates/disabled-app-email";
|
||||
import type { Feedback } from "./templates/feedback-email";
|
||||
import FeedbackEmail from "./templates/feedback-email";
|
||||
@@ -337,6 +339,10 @@ export const sendEmailVerificationCode = async (verificationInput: EmailVerifyCo
|
||||
await sendEmail(() => new AttendeeVerifyEmail(verificationInput));
|
||||
};
|
||||
|
||||
export const sendChangeOfEmailVerificationLink = async (verificationInput: ChangeOfEmailVerifyLink) => {
|
||||
await sendEmail(() => new ChangeOfEmailVerifyEmail(verificationInput));
|
||||
};
|
||||
|
||||
export const sendRequestRescheduleEmail = async (
|
||||
calEvent: CalendarEvent,
|
||||
metadata: { rescheduleLink: string }
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import type { TFunction } from "next-i18next";
|
||||
|
||||
import { APP_NAME, SENDER_NAME, SUPPORT_MAIL_ADDRESS } from "@calcom/lib/constants";
|
||||
|
||||
import { BaseEmailHtml, CallToAction } from "../components";
|
||||
|
||||
export type EmailVerifyLink = {
|
||||
language: TFunction;
|
||||
user: {
|
||||
name?: string | null;
|
||||
emailFrom: string;
|
||||
emailTo: string;
|
||||
};
|
||||
verificationEmailLink: string;
|
||||
};
|
||||
|
||||
export const VerifyEmailChangeEmail = (
|
||||
props: EmailVerifyLink & Partial<React.ComponentProps<typeof BaseEmailHtml>>
|
||||
) => {
|
||||
return (
|
||||
<BaseEmailHtml subject={props.language("change_of_email", { appName: APP_NAME })}>
|
||||
<p
|
||||
style={{
|
||||
fontWeight: 600,
|
||||
fontSize: "24px",
|
||||
lineHeight: "32px",
|
||||
}}>
|
||||
<>{props.language("change_of_email", { appName: APP_NAME })}</>
|
||||
</p>
|
||||
<p style={{ fontWeight: 400 }}>
|
||||
<>{props.language("hi_user_name", { name: props.user.name })}!</>
|
||||
</p>
|
||||
<p style={{ fontWeight: 400, lineHeight: "24px" }}>
|
||||
<>{props.language("verify_email_change_description", { appName: APP_NAME })}</>
|
||||
</p>
|
||||
<div
|
||||
style={{
|
||||
marginTop: "2rem",
|
||||
marginBottom: "2rem",
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
}}>
|
||||
<div
|
||||
style={{
|
||||
width: "100%",
|
||||
}}>
|
||||
<span
|
||||
style={{
|
||||
display: "block",
|
||||
fontSize: "14px",
|
||||
lineHeight: 0.5,
|
||||
}}>
|
||||
{props.language("old_email_address")}
|
||||
</span>
|
||||
<p
|
||||
style={{
|
||||
color: `#6B7280`,
|
||||
lineHeight: 1,
|
||||
fontWeight: 400,
|
||||
}}>
|
||||
{props.user.emailFrom}
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
width: "100%",
|
||||
}}>
|
||||
<span
|
||||
style={{
|
||||
display: "block",
|
||||
fontSize: "14px",
|
||||
lineHeight: 0.5,
|
||||
}}>
|
||||
{props.language("new_email_address")}
|
||||
</span>
|
||||
<p
|
||||
style={{
|
||||
color: `#6B7280`,
|
||||
lineHeight: 1,
|
||||
fontWeight: 400,
|
||||
}}>
|
||||
{props.user.emailTo}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<CallToAction label={props.language("verify_email_email_button")} href={props.verificationEmailLink} />
|
||||
<div style={{ lineHeight: "6px" }}>
|
||||
<p style={{ fontWeight: 400, lineHeight: "24px" }}>
|
||||
<>
|
||||
{props.language("happy_scheduling")}, <br />
|
||||
<a
|
||||
href={`mailto:${SUPPORT_MAIL_ADDRESS}`}
|
||||
style={{ color: "#3E3E3E" }}
|
||||
target="_blank"
|
||||
rel="noreferrer">
|
||||
<>{props.language("the_calcom_team", { companyName: SENDER_NAME })}</>
|
||||
</a>
|
||||
</>
|
||||
</p>
|
||||
</div>
|
||||
</BaseEmailHtml>
|
||||
);
|
||||
};
|
||||
@@ -32,3 +32,4 @@ export { OrgAutoInviteEmail } from "./OrgAutoInviteEmail";
|
||||
export { MonthlyDigestEmail } from "./MonthlyDigestEmail";
|
||||
export { AdminOrganizationNotificationEmail } from "./AdminOrganizationNotificationEmail";
|
||||
export { BookingRedirectEmailNotification } from "./BookingRedirectEmailNotification";
|
||||
export { VerifyEmailChangeEmail } from "./VerifyEmailChangeEmail";
|
||||
@@ -0,0 +1,55 @@
|
||||
import type { TFunction } from "next-i18next";
|
||||
|
||||
import { APP_NAME, COMPANY_NAME } from "@calcom/lib/constants";
|
||||
|
||||
import { renderEmail } from "../";
|
||||
import BaseEmail from "./_base-email";
|
||||
|
||||
export type ChangeOfEmailVerifyLink = {
|
||||
language: TFunction;
|
||||
user: {
|
||||
name?: string | null;
|
||||
emailFrom: string;
|
||||
emailTo: string;
|
||||
};
|
||||
verificationEmailLink: string;
|
||||
};
|
||||
|
||||
export default class ChangeOfEmailVerifyEmail extends BaseEmail {
|
||||
changeEvent: ChangeOfEmailVerifyLink;
|
||||
|
||||
constructor(changeEvent: ChangeOfEmailVerifyLink) {
|
||||
super();
|
||||
this.name = "SEND_ACCOUNT_VERIFY_EMAIL";
|
||||
this.changeEvent = changeEvent;
|
||||
}
|
||||
|
||||
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
|
||||
return {
|
||||
to: `${this.changeEvent.user.name} <${this.changeEvent.user.emailTo}>`,
|
||||
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
|
||||
subject: this.changeEvent.language("change_of_email", {
|
||||
appName: APP_NAME,
|
||||
}),
|
||||
html: await renderEmail("VerifyEmailChangeEmail", this.changeEvent),
|
||||
text: this.getTextBody(),
|
||||
};
|
||||
}
|
||||
|
||||
protected getTextBody(): string {
|
||||
return `
|
||||
${this.changeEvent.language("verify_email_subject", { appName: APP_NAME })}
|
||||
${this.changeEvent.language("verify_email_email_header")}
|
||||
${this.changeEvent.language("hi_user_name", { name: this.changeEvent.user.name })},
|
||||
${this.changeEvent.language("verify_email_change_description", { appName: APP_NAME })}
|
||||
${this.changeEvent.language("old_email_address")}
|
||||
${this.changeEvent.user.emailFrom},
|
||||
${this.changeEvent.language("new_email_address")}
|
||||
${this.changeEvent.user.emailTo},
|
||||
${this.changeEvent.verificationEmailLink}
|
||||
${this.changeEvent.language("happy_scheduling")} ${this.changeEvent.language("the_calcom_team", {
|
||||
companyName: COMPANY_NAME,
|
||||
})}
|
||||
`.replace(/(<([^>]+)>)/gi, "");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user