passwordRequest.js 926 B

12345678910111213141516171819202122232425262728293031
  1. import config from "config";
  2. import mail from "../index";
  3. /**
  4. * Sends a request password email
  5. *
  6. * @param {string} to - the email address of the recipient
  7. * @param {string} username - the username of the recipient
  8. * @param {string} code - the password code of the recipient
  9. * @param {Function} cb - gets called when an error occurred or when the operation was successful
  10. */
  11. export default (to, username, code, cb) => {
  12. const data = {
  13. from: config.get("mail.from"),
  14. to,
  15. subject: "Password request",
  16. html: `
  17. Hello there ${username},
  18. <br>
  19. <br>
  20. Someone has requested to add a password to your account. If this was not you, you can ignore this email.
  21. <br>
  22. <br>
  23. The code is <b>${code}</b>. You can enter this code on the page you requested the password on. This code will expire in 24 hours.
  24. `
  25. };
  26. mail.runJob("SEND_MAIL", { data })
  27. .then(() => cb())
  28. .catch(err => cb(err));
  29. };