Skip to content

The Open Source DocuSign Alternative.

Send email on password reset complete

Ephraim Atta-Duncan5d2349086d3a
diff --git a/apps/web/pages/api/auth/forgot-password.ts b/apps/web/pages/api/auth/forgot-password.ts
index ef2b218d7..e30eeed36 100644
--- a/apps/web/pages/api/auth/forgot-password.ts
+++ b/apps/web/pages/api/auth/forgot-password.ts
@@ -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";
diff --git a/apps/web/pages/api/auth/reset-password.ts b/apps/web/pages/api/auth/reset-password.ts
index ad6ef7a49..4bf2e5306 100644
--- a/apps/web/pages/api/auth/reset-password.ts
+++ b/apps/web/pages/api/auth/reset-password.ts
@@ -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." });
}
diff --git a/apps/web/pages/auth/reset.tsx b/apps/web/pages/auth/reset.tsx
new file mode 100644
index 000000000..e69de29bb
diff --git a/packages/lib/mail/index.ts b/packages/lib/mail/index.ts
index 8388608c6..e4d66dc44 100644
--- a/packages/lib/mail/index.ts
+++ b/packages/lib/mail/index.ts
@@ -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";
diff --git a/packages/lib/mail/resetPasswordSuccessTemplate.ts b/packages/lib/mail/resetPasswordSuccessTemplate.ts
new file mode 100644
index 000000000..44afcc119
--- /dev/null
+++ b/packages/lib/mail/resetPasswordSuccessTemplate.ts
@@ -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:[email protected]">[email protected]</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;
diff --git a/packages/lib/mail/sendResetPasswordSuccessMail.ts b/packages/lib/mail/sendResetPasswordSuccessMail.ts
new file mode 100644
index 000000000..6877700fb
--- /dev/null
+++ b/packages/lib/mail/sendResetPasswordSuccessMail.ts
@@ -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;
+ }
+ );
+};
diff --git a/packages/lib/mail/signingCompleteTemplate.ts b/packages/lib/mail/signingCompleteTemplate.ts
index 212e1f8ea..e32162906 100644
--- a/packages/lib/mail/signingCompleteTemplate.ts
+++ b/packages/lib/mail/signingCompleteTemplate.ts
@@ -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 = `