"use strict"; (() => { var exports = {}; exports.id = 8426; exports.ids = [8426]; exports.modules = { /***/ 5184: /***/ ((module) => { module.exports = require("nodemailer"); /***/ }), /***/ 2261: /***/ ((module) => { module.exports = require("serverless-mysql"); /***/ }), /***/ 4300: /***/ ((module) => { module.exports = require("buffer"); /***/ }), /***/ 6113: /***/ ((module) => { module.exports = require("crypto"); /***/ }), /***/ 7147: /***/ ((module) => { module.exports = require("fs"); /***/ }), /***/ 3685: /***/ ((module) => { module.exports = require("http"); /***/ }), /***/ 9842: /***/ ((module) => { // @ts-check /** * Delay async function * * @param {number} [milliseconds] * * @returns {Promise} new user auth object payload */ module.exports = async function delay(milliseconds) { await new Promise((resolve, reject)=>{ setTimeout(()=>{ resolve(true); }, milliseconds || 1000); }); return true; }; //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// /***/ }), /***/ 8647: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ handler) /* harmony export */ }); /* harmony import */ var _functions_backend_delay__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9842); /* harmony import */ var _functions_backend_delay__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_delay__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6825); /* harmony import */ var _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_1__); // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ const fs = __webpack_require__(7147); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// const handleNodemailer = __webpack_require__(6926); const encrypt = __webpack_require__(7547); /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * API handler * ============================================================================== * @type {import("next").NextApiHandler} */ async function handler(req, res) { if (req.method === "GET") { //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// let generatedToken = encrypt(JSON.stringify({ email: req.query.email, dateCode: Date.now() })); let host = process.env.DSQL_HOST; const email = req.query.email; if (!String(email).match(/.*@.*\..*/)) return res.json({ user: null, msg: "Invalid Email" }); const ip = req.headers["x-real-ip"] || req.headers["x-forwarded-for"] || req.connection.remoteAddress; const site = process.env.DSQL_HOST || "https://datasquirel.com"; let mail = await handleNodemailer({ to: req.query.email?.toString() || process.env.DSQL_CONTACT_EMAIL, subject: "Reset Your Password", text: "Please click the link to reset your password", html: fs.readFileSync("./email/send-password-reset-link.html", "utf8").replace(/{{host}}/, host || "").replace(/{{ip}}/, String(ip)).replace(/{{token}}/, generatedToken || ""), alias: "Support" }); await _functions_backend_delay__WEBPACK_IMPORTED_MODULE_0___default()(); handleNodemailer({ to: process.env.DSQL_CONTACT_EMAIL, subject: `Password Reset Attempt for ${email}`, html: `

${email} tried to reset password

${email} attempted a password reset on ${site} from ${ip} with a wrong password.

` }); //////////////////////////////////////// if (!mail) return res.json({ success: false }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// res.json({ success: true }); } } /***/ }) }; ; // load runtime var __webpack_require__ = require("../../webpack-api-runtime.js"); __webpack_require__.C(exports); var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId)) var __webpack_exports__ = __webpack_require__.X(0, [2224,6825,3017,7547,6926], () => (__webpack_exec__(8647))); module.exports = __webpack_exports__; })();