simple-auth-cli
Version:
An implementation of authentication system supporting multiple providers ready to be used with a single command.
32 lines (31 loc) • 7.33 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateEmailTemplates = void 0;
var constants_js_1 = require("../constants.js");
var generateEmailTemplates = function (username, token, email, reason) {
if (email === void 0) { email = ""; }
if (reason === void 0) { reason = ""; }
var html;
var link = ""; // Define the link dynamically
switch (reason) {
case "verify":
link = "".concat(constants_js_1.APPURL, "/auth/verify/?token=").concat(token);
html = "\n<body style=\"font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f4f4f4;\">\n <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n <tr>\n <td align=\"center\">\n <table width=\"600px\" style=\"background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0px 0px 10px rgba(0,0,0,0.1);\">\n <tr>\n <td align=\"center\">\n <h2 style=\"color: #333;\">Verify Your ".concat(constants_js_1.APPNAME, " Account</h2>\n <p style=\"color: #555;\">Hello ").concat(username, ",</p>\n <p>Thank you for signing up! Please verify your email by clicking the button below.</p>\n <a href=\"").concat(link, "\" style=\"display: inline-block; background: #007bff; color: #fff; padding: 10px 20px; text-decoration: none; border-radius: 5px;\">Verify Email</a>\n <p>If the button does not work, copy and paste this link into your browser:</p>\n <p><a href=\"").concat(link, "\" style=\"color: #007bff;\">").concat(link, "</a></p>\n <p>If you didn't create an account, please ignore this email.</p>\n <p style=\"color: #777;\">- The ").concat(constants_js_1.APPNAME, " Team</p>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n</body>");
break;
case "forgotPassword":
link = "".concat(constants_js_1.APPURL, "/auth/reset-password/?token=").concat(token);
html = "\n<body style=\"font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f4f4f4;\">\n <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n <tr>\n <td align=\"center\">\n <table width=\"600px\" style=\"background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0px 0px 10px rgba(0,0,0,0.1);\">\n <tr>\n <td align=\"center\">\n <h2 style=\"color: #333;\">Reset Your Password</h2>\n <p style=\"color: #555;\">Hello ".concat(username, ",</p>\n <p>We received a request to reset your password. Click the button below to reset it:</p>\n <a href=\"").concat(link, "\" style=\"display: inline-block; background: #ff5733; color: #fff; padding: 10px 20px; text-decoration: none; border-radius: 5px;\">Reset Password</a>\n <p>If the button does not work, copy and paste this link into your browser:</p>\n <p><a href=\"").concat(link, "\" style=\"color: #007bff;\">").concat(link, "</a></p>\n <p>If you didn\u2019t request this, you can safely ignore this email.</p>\n <p style=\"color: #777;\">- The ").concat(constants_js_1.APPNAME, " Team</p>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n</body>");
break;
case "emailChange":
html = "\n<body style=\"font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f4f4f4;\">\n <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n <tr>\n <td align=\"center\">\n <table width=\"600px\" style=\"background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0px 0px 10px rgba(0,0,0,0.1);\">\n <tr>\n <td align=\"center\">\n <h2 style=\"color: #333;\">Your Sign-In Email Was Changed</h2>\n <p style=\"color: #555;\">Hello ".concat(username, ",</p>\n <p>Your email address was successfully changed to <strong>").concat(email, "</strong>.</p>\n <p>If this wasn\u2019t you, please contact our support team immediately.</p>\n <p style=\"color: #777;\">- The ").concat(constants_js_1.APPNAME, " Team</p>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n</body>");
break;
case "emailChangeVerification":
link = "".concat(constants_js_1.APPURL, "/auth/verify-email-change/?token=").concat(token);
html = "\n<body style=\"font-family: Arial, sans-serif; background-color: #f4f4f4; margin: 0; padding: 0;\">\n <div style=\"width: 100%; max-width: 600px; margin: 20px auto; background: #ffffff; padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\">\n <div style=\"text-align: center; padding: 10px 0;\">\n <h1 style=\"color: #333; margin: 0;\">".concat(constants_js_1.APPNAME, "</h1>\n </div>\n <div style=\"padding: 20px; text-align: center; color: #555;\">\n <h2 style=\"color: #333; margin-bottom: 20px;\">Email Change Request</h2>\n <p style=\"font-size: 16px; line-height: 1.5; margin-bottom: 20px;\">\n Hi <strong>").concat(username, "</strong>,\n </p>\n <p style=\"font-size: 16px; line-height: 1.5; margin-bottom: 20px;\">\n We received a request to change your sign-in email on <strong>").concat(constants_js_1.APPNAME, "</strong>.\n </p>\n <p style=\"font-size: 16px; line-height: 1.5; margin-bottom: 20px;\">\n If this was you, please confirm your new email by clicking the button below:\n </p>\n <a href=\"").concat(link, "\" \n style=\"display: inline-block; padding: 12px 20px; color: #ffffff; background-color: #007BFF; text-decoration: none; font-weight: bold; border-radius: 5px; font-size: 16px;\">\n Verify Email Change\n </a>\n <p>If the button does not work, copy and paste this link into your browser:</p>\n <p><a href=\"").concat(link, "\" style=\"color: #007bff;\">").concat(link, "</a></p>\n <p style=\"font-size: 16px; line-height: 1.5; margin-top: 20px;\">\n If you did not request this, please ignore this email. Your email will remain unchanged.\n </p>\n </div>\n <div style=\"text-align: center; padding: 10px; font-size: 12px; color: #888;\">\n <p style=\"color: #777;\">- The ").concat(constants_js_1.APPNAME, " Team</p>\n </div>\n </div>\n</body>");
break;
default:
html = null;
}
return html;
};
exports.generateEmailTemplates = generateEmailTemplates;