From 86f66f8eedf6cafe53ae446ef43983e7e340368e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 16 Dec 2024 11:30:06 +0900 Subject: [PATCH] api --- .../emails/templates/ConfirmUpdateEmail.tsx | 67 ++++++++++++++++++ server/models/User.ts | 33 +++++++++ server/routes/api/users/schema.ts | 27 +++++++- server/routes/api/users/users.ts | 69 +++++++++++++++++++ server/utils/jwt.ts | 30 ++++++++ shared/utils/routeHelpers.ts | 4 ++ 6 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 server/emails/templates/ConfirmUpdateEmail.tsx diff --git a/server/emails/templates/ConfirmUpdateEmail.tsx b/server/emails/templates/ConfirmUpdateEmail.tsx new file mode 100644 index 0000000000..204cd57a3b --- /dev/null +++ b/server/emails/templates/ConfirmUpdateEmail.tsx @@ -0,0 +1,67 @@ +import * as React from "react"; +import env from "@server/env"; +import BaseEmail, { EmailMessageCategory, EmailProps } from "./BaseEmail"; +import Body from "./components/Body"; +import Button from "./components/Button"; +import EmailTemplate from "./components/EmailLayout"; +import EmptySpace from "./components/EmptySpace"; +import Footer from "./components/Footer"; +import Header from "./components/Header"; +import Heading from "./components/Heading"; + +type Props = EmailProps & { + token: string; +}; + +/** + * Email sent to a user when they request to change their email. + */ +export default class ConfirmUpdateEmail extends BaseEmail { + protected get category() { + return EmailMessageCategory.Authentication; + } + + protected subject() { + return `Your email update request`; + } + + protected preview() { + return `Here’s your email change confirmation.`; + } + + protected renderAsText({ token }: Props): string { + return ` +You requested to update your ${env.APP_NAME} account email. Please +follow the link below to confirm the change. + + ${this.updateLink(token)} + + `; + } + + protected render({ token }: Props) { + return ( + +
+ + + Your email update request +

+ You requested to update your {env.APP_NAME} account email. Please + click below to confirm the change. +

+ +

+ +

+ + +