mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
Send email on password reset complete
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import { sendResetPassword } from "@documenso/lib/mail";
|
||||
import { sendResetPassword, sendResetPasswordSuccessMail } from "@documenso/lib/mail";
|
||||
import { defaultHandler, defaultResponder } from "@documenso/lib/server";
|
||||
import prisma from "@documenso/prisma";
|
||||
import crypto from "crypto";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import { hashPassword } from "@documenso/lib/auth";
|
||||
import { sendResetPassword } from "@documenso/lib/mail";
|
||||
import { sendResetPasswordSuccessMail } from "@documenso/lib/mail";
|
||||
import { defaultHandler, defaultResponder } from "@documenso/lib/server";
|
||||
import prisma from "@documenso/prisma";
|
||||
|
||||
@ -47,6 +47,8 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
return res.status(500).json({ message: "Error resetting password." });
|
||||
}
|
||||
|
||||
await sendResetPasswordSuccessMail(foundToken.User);
|
||||
|
||||
res.status(200).json({ message: "Password reset successful." });
|
||||
}
|
||||
|
||||
|
||||
0
apps/web/pages/auth/reset.tsx
Normal file
0
apps/web/pages/auth/reset.tsx
Normal file
@ -4,3 +4,5 @@ export { sendSigningRequest as sendSigningRequest } from "./sendSigningRequest";
|
||||
export { sendSigningDoneMail } from "./sendSigningDoneMail";
|
||||
export { resetPasswordTemplate } from "./resetPasswordTemplate";
|
||||
export { sendResetPassword } from "./sendResetPassword";
|
||||
export { resetPasswordSuccessTemplate } from "./resetPasswordSuccessTemplate";
|
||||
export { sendResetPasswordSuccessMail } from "./sendResetPasswordSuccessMail";
|
||||
|
||||
51
packages/lib/mail/resetPasswordSuccessTemplate.ts
Normal file
51
packages/lib/mail/resetPasswordSuccessTemplate.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import { NEXT_PUBLIC_WEBAPP_URL } from "../constants";
|
||||
import { User } from "@prisma/client";
|
||||
|
||||
export const resetPasswordSuccessTemplate = (user: User) => {
|
||||
return `
|
||||
<div style="background-color: #eaeaea; padding: 2%;">
|
||||
<div
|
||||
style="text-align:left; margin: auto; font-size: 14px; color: #353434; max-width: 500px; border-radius: 0.375rem; background: white; padding: 50px">
|
||||
<img src="${NEXT_PUBLIC_WEBAPP_URL}/logo_h.png" alt="Documenso Logo"
|
||||
style="width: 180px; display: block; margin-bottom: 14px;" />
|
||||
|
||||
<h2 style="text-align: left; margin-top: 20px; font-size: 24px; font-weight: bold">Password updated!</h2>
|
||||
|
||||
<p style="margin-top: 15px">
|
||||
Hi ${user.name ? user.name : user.email},
|
||||
</p>
|
||||
|
||||
<p style="margin-top: 15px">
|
||||
We've changed your password as you asked. You can now sign in with your new password.
|
||||
</p>
|
||||
|
||||
<p style="margin-top: 15px">
|
||||
If you did not ask to change your password we are here to help you secure your account, just <a href="https://documenso.com">contact us</a>.
|
||||
</p>
|
||||
|
||||
<p style="margin-top: 15px">
|
||||
<p style="font-weight: bold">
|
||||
The Documenso Team
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<p style="text-align:left; margin-top: 30px">
|
||||
<small>Want to send you own signing links?
|
||||
<a href="https://documenso.com">Hosted Documenso is here!</a>.</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div style="text-align: left; line-height: 18px; color: #666666; margin: 24px">
|
||||
<div style="margin-top: 12px">
|
||||
<b>Need help?</b>
|
||||
<br>
|
||||
Contact us at <a href="mailto:hi@documenso.com">hi@documenso.com</a>
|
||||
</div>
|
||||
<hr size="1" style="height: 1px; border: none; color: #D8D8D8; background-color: #D8D8D8">
|
||||
<div style="text-align: center">
|
||||
<small>Easy and beautiful document signing by Documenso.</small>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
export default resetPasswordSuccessTemplate;
|
||||
11
packages/lib/mail/sendResetPasswordSuccessMail.ts
Normal file
11
packages/lib/mail/sendResetPasswordSuccessMail.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import resetPasswordSuccessTemplate from "./resetPasswordSuccessTemplate";
|
||||
import { sendMail } from "./sendMail";
|
||||
import { User } from "@prisma/client";
|
||||
|
||||
export const sendResetPasswordSuccessMail = async (user: User) => {
|
||||
await sendMail(user.email, "Password Reset Success!", resetPasswordSuccessTemplate(user)).catch(
|
||||
(err) => {
|
||||
throw err;
|
||||
}
|
||||
);
|
||||
};
|
||||
@ -1,6 +1,5 @@
|
||||
import { NEXT_PUBLIC_WEBAPP_URL } from "../constants";
|
||||
import { baseEmailTemplate } from "./baseTemplate";
|
||||
import { Document as PrismaDocument } from "@prisma/client";
|
||||
|
||||
export const signingCompleteTemplate = (message: string) => {
|
||||
const customContent = `
|
||||
|
||||
Reference in New Issue
Block a user