aegis-auth
Version:
A credentials-based auth solution for Next.js (and other Node projects) with IP rate-limiting, account lockouts, and sessions in DB.
38 lines • 1.2 kB
JavaScript
import { sendEmail } from "./sendEmail";
export async function sendPasswordResetEmail(options) {
var _a, _b;
const { toEmail, token, config } = options;
let html;
if ((_b = (_a = config.email) === null || _a === void 0 ? void 0 : _a.templates) === null || _b === void 0 ? void 0 : _b.passwordReset) {
html = config.email.templates.passwordReset({ token, toEmail });
}
else {
html = `
<html>
<body>
<p>You requested a password reset. Click the link below to reset your password:</p>
<a href="${config.email.baseUrl}/reset-password?token=${token}">Reset Password</a>
</body>
</html>
`;
}
const sendOption = {
to: toEmail,
subject: "Reset your password",
html: html,
config: config,
};
try {
const result = await sendEmail(sendOption);
config.logger.info("Password reset email sent", { toEmail, result });
return result;
}
catch (error) {
config.logger.error("Failed to send password reset email", {
toEmail,
error,
});
throw error;
}
}
//# sourceMappingURL=sendPasswordResetEmail.js.map