128 lines
4.0 KiB
JavaScript
128 lines
4.0 KiB
JavaScript
|
"use strict";
|
||
|
(() => {
|
||
|
var exports = {};
|
||
|
exports.id = 5110;
|
||
|
exports.ids = [5110];
|
||
|
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");
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 1017:
|
||
|
/***/ ((module) => {
|
||
|
|
||
|
module.exports = require("path");
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 4991:
|
||
|
/***/ ((__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_userAuth__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6825);
|
||
|
/* harmony import */ var _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_0__);
|
||
|
// @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") {
|
||
|
/** ********************* User Auth */ let user = await _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_0___default()(req, res);
|
||
|
if (!user) return res.redirect(307, "/logout");
|
||
|
// return;
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
let generatedToken = encrypt(JSON.stringify({
|
||
|
id: user.id,
|
||
|
email: user.email,
|
||
|
dateCode: Date.now()
|
||
|
}));
|
||
|
let host = process.env.DSQL_HOST;
|
||
|
let mail = await handleNodemailer({
|
||
|
to: user.email,
|
||
|
subject: "Verify Email Address",
|
||
|
text: "Please click the link to verify your email address",
|
||
|
html: fs.readFileSync("./email/send-email-verification-link.html", "utf8").replace(/{{host}}/, host || "").replace(/{{token}}/, generatedToken || "")
|
||
|
});
|
||
|
////////////////////////////////////////
|
||
|
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, [5425,2224,6825,3017,7547,6926], () => (__webpack_exec__(4991)));
|
||
|
module.exports = __webpack_exports__;
|
||
|
|
||
|
})();
|