From f539f2d04ceb1e7bf74fe53524b5c09e7a77fd7e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 17 Dec 2024 16:48:28 +0900 Subject: [PATCH] fix translation, improve email clarity --- app/components/UserDialogs.tsx | 9 +++++---- .../emails/templates/ConfirmUpdateEmail.tsx | 19 +++++++++++-------- server/routes/api/users/users.ts | 4 +++- shared/i18n/locales/en_US/translation.json | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/components/UserDialogs.tsx b/app/components/UserDialogs.tsx index 6153edd53c..6022c2d105 100644 --- a/app/components/UserDialogs.tsx +++ b/app/components/UserDialogs.tsx @@ -7,6 +7,7 @@ import ConfirmationDialog from "~/components/ConfirmationDialog"; import Input from "~/components/Input"; import useStores from "~/hooks/useStores"; import { client } from "~/utils/ApiClient"; +import Text from "./Text"; type Props = { user: User; @@ -160,12 +161,12 @@ export function UserChangeEmailDialog({ user, onSubmit }: Props) { savingText={`${t("Saving")}…`} disabled={!email || email === user.email} > - -

+ + You will receive an email to verify your new address. It must be unique in the workspace. -

-
+ + { return `Here’s your email change confirmation.`; } - protected renderAsText({ code }: Props): string { + protected renderAsText({ teamUrl, code, to }: Props): string { return ` You requested to update your ${env.APP_NAME} account email. Please -follow the link below to confirm the change. +follow the link below to confirm the change to ${to}. - ${this.updateLink(code)} + ${this.updateLink(teamUrl, code)} `; } - protected render({ code }: Props) { + protected render({ teamUrl, code, to }: Props) { return (
@@ -48,11 +49,13 @@ follow the link below to confirm the change. Your email update request

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

- +

@@ -61,7 +64,7 @@ follow the link below to confirm the change. ); } - private updateLink(code: string): string { - return `${env.URL}/api/users.updateEmail?code=${code}`; + private updateLink(teamUrl: string, code: string): string { + return `${teamUrl}/api/users.updateEmail?code=${code}`; } } diff --git a/server/routes/api/users/users.ts b/server/routes/api/users/users.ts index a475c5e61d..7e7a226bae 100644 --- a/server/routes/api/users/users.ts +++ b/server/routes/api/users/users.ts @@ -212,13 +212,14 @@ router.post( async (ctx: APIContext) => { const { user: actor } = ctx.state.auth; const { id } = ctx.input.body; + const { team } = actor; const user = id ? await User.findByPk(id) : actor; const email = ctx.input.body.email.trim().toLowerCase(); authorize(actor, "update", user); // Check if email domain is allowed - if (!(await actor.team.isDomainAllowed(email))) { + if (!(await team.isDomainAllowed(email))) { throw DomainNotAllowedError(); } @@ -230,6 +231,7 @@ router.post( await new ConfirmUpdateEmail({ to: email, code: user.getEmailUpdateToken(email), + teamUrl: team.url, }).schedule(); ctx.body = { diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 3c67a614a5..78302a759a 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -403,7 +403,7 @@ "New name": "New name", "Name can't be empty": "Name can't be empty", "Check your email to verify the new address.": "Check your email to verify the new address.", - "<0>You will receive an email to verify your new address. It must be unique in the workspace.": "<0>You will receive an email to verify your new address. It must be unique in the workspace.", + "You will receive an email to verify your new address. It must be unique in the workspace.": "You will receive an email to verify your new address. It must be unique in the workspace.", "New email": "New email", "Email can't be empty": "Email can't be empty", "Your import completed": "Your import completed",