fix: Use user locale for sending password resets (#10104)

This commit is contained in:
Alex van Andel authored and GitHub committed 2023-07-12 12:04:07 -07:00
1 parent 3328cb2226
commit 3009f17cb0
2 files changed
+5 -4

No files matched your search

+3 -2
View File
@@ -11,8 +11,6 @@ import { getTranslation } from "@calcom/lib/server/i18n";
import prisma from "@calcom/prisma";
async function handler(req: NextApiRequest, res: NextApiResponse) {
const t = await getTranslation(req.body.language ?? "en", "common");
const email = z
.string()
.email()
@@ -47,6 +45,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
name: true,
identityProvider: true,
email: true,
locale: true,
},
});
@@ -57,6 +56,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
.json({ message: "If this email exists in our system, you should receive a Reset email." });
}
const t = await getTranslation(maybeUser.locale ?? "en", "common");
const maybePreviousRequest = await prisma.resetPasswordRequest.findMany({
where: {
email: maybeUser.email,
@@ -15,7 +15,7 @@ import PageWrapper from "@components/PageWrapper";
import AuthContainer from "@components/ui/AuthContainer";
export default function ForgotPassword({ csrfToken }: { csrfToken: string }) {
const { t, i18n } = useLocale();
const { t } = useLocale();
const [loading, setLoading] = React.useState(false);
const [error, setError] = React.useState<{ message: string } | null>(null);
const [success, setSuccess] = React.useState(false);
@@ -31,7 +31,7 @@ export default function ForgotPassword({ csrfToken }: { csrfToken: string }) {
try {
const res = await fetch("/api/auth/forgot-password", {
method: "POST",
body: JSON.stringify({ email: email, language: i18n.language }),
body: JSON.stringify({ email }),
headers: {
"Content-Type": "application/json",
},