"use strict"; (() => { var exports = {}; exports.id = 3115; exports.ids = [3115]; exports.modules = { /***/ 9538: /***/ ((module) => { module.exports = require("datasquirel"); /***/ }), /***/ 3785: /***/ ((module) => { module.exports = require("generate-password"); /***/ }), /***/ 6517: /***/ ((module) => { module.exports = require("lodash"); /***/ }), /***/ 5184: /***/ ((module) => { module.exports = require("nodemailer"); /***/ }), /***/ 6109: /***/ ((module) => { module.exports = require("sanitize-html"); /***/ }), /***/ 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"); /***/ }), /***/ 5687: /***/ ((module) => { module.exports = require("https"); /***/ }), /***/ 1017: /***/ ((module) => { module.exports = require("path"); /***/ }), /***/ 7310: /***/ ((module) => { module.exports = require("url"); /***/ }), /***/ 5389: /***/ ((__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_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7839); /* harmony import */ var _functions_backend_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _shell_utils_camelJoinedtoCamelSpace__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2127); /* harmony import */ var _shell_utils_camelJoinedtoCamelSpace__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_shell_utils_camelJoinedtoCamelSpace__WEBPACK_IMPORTED_MODULE_1__); // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ const githubLogin = __webpack_require__(6069); ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// /** * API handler * ============================================================================== * @type {import("next").NextApiHandler} */ async function handler(req, res) { /** * Check method * * @description Check request method and return if invalid */ if (req.method !== "GET") return res.json({ msg: "Failed!" }); //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// /** * User auth * * @description Authenticate user */ const { code , email , invite } = req.query; //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// /** * Send Response * * @description Send a boolean response */ try { /** * Create new user folder and file * * @description Create new user folder and file */ const gitHubUser = await githubLogin({ code: code?.toString() || "", clientId: process.env.DSQL_GITHUB_ID || "", clientSecret: process.env.DSQL_GITHUB_SECRET || "" }); if (!gitHubUser) { return res.json({ success: false, msg: "No github user returned" }); } if (!gitHubUser?.email && !email) { return res.json({ success: false, msg: "Github User Email not present" }); } const loggedInGithubUser = await _functions_backend_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_0___default()({ email: gitHubUser.email, payload: { email: gitHubUser.email, first_name: _shell_utils_camelJoinedtoCamelSpace__WEBPACK_IMPORTED_MODULE_1___default()(gitHubUser.login)?.split(" ")[0], last_name: _shell_utils_camelJoinedtoCamelSpace__WEBPACK_IMPORTED_MODULE_1___default()(gitHubUser.login)?.split(" ")[1], social_id: gitHubUser.id, social_platform: "github", image: gitHubUser.avatar_url, image_thumbnail: gitHubUser.avatar_url, username: "github-user-" + gitHubUser.name }, social_platform: "github", invitation: invite, res: res, social_id: gitHubUser.id, supEmail: email ? email.toString() : undefined }); //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// res.json(loggedInGithubUser); //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// } catch (/** @type {any} */ error) { //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// console.log("ERROR in 'github-auth' API route =>", error.message); // serverError({ // component: "/api/social-login/github-auth/catch-error", // message: error.message, // user: user, // }); res.json({ success: false, msg: "Failed!" }); //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// } } /***/ }) }; ; // 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,2163,3017,3403,7547,5886,5338,8326,1311,6926,7487,613,4294,6968,722,9971], () => (__webpack_exec__(5389))); module.exports = __webpack_exports__; })();