151 lines
5.5 KiB
JavaScript
151 lines
5.5 KiB
JavaScript
"use strict";
|
|
(() => {
|
|
var exports = {};
|
|
exports.id = 4265;
|
|
exports.ids = [4265];
|
|
exports.modules = {
|
|
|
|
/***/ 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");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 3990:
|
|
/***/ ((__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 _package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2224);
|
|
/* harmony import */ var _package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_package_shared_utils_backend_global_db_DB_HANDLER__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
|
|
* ==============================================================================
|
|
*/
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* 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 user = await _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_1___default()(req, res);
|
|
if (!user) {
|
|
return res.json({
|
|
success: false,
|
|
msg: "Unauthorized"
|
|
});
|
|
}
|
|
/**
|
|
* User auth
|
|
*
|
|
* @description Authenticate user
|
|
*/ const delegetedDbAccess = await _package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_0___default()(`
|
|
SELECT
|
|
user_users.user_id,user_users.database_access,user_users.user_id,user_users.user_priviledge,users.first_name,users.last_name,users.email,users.image_thumbnail
|
|
FROM
|
|
user_users JOIN users ON user_users.user_id=users.id
|
|
WHERE
|
|
user_users.invited_user_id='${user.id}'
|
|
`);
|
|
let databasesArray = [];
|
|
if (delegetedDbAccess && delegetedDbAccess[0]) {
|
|
for(let i = 0; i < delegetedDbAccess.length; i++){
|
|
const deleDbAccessObject = delegetedDbAccess[i];
|
|
const { database_access , user_id , user_priviledge } = deleDbAccessObject;
|
|
if (!database_access?.match(/./)) continue;
|
|
const delegetedDbs = await _package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_0___default()(`SELECT * FROM user_databases WHERE (${database_access.split("|").map((/** @type {string} */ db)=>`db_slug='${db}'`).join(" OR ")}) AND user_id=${user_id}`);
|
|
for(let j = 0; j < delegetedDbs.length; j++){
|
|
const delegetedDb = delegetedDbs[j];
|
|
databasesArray.push({
|
|
id: delegetedDb.id,
|
|
user_id: deleDbAccessObject.user_id,
|
|
first_name: deleDbAccessObject.first_name,
|
|
last_name: deleDbAccessObject.last_name,
|
|
email: deleDbAccessObject.email,
|
|
image_thumbnail: deleDbAccessObject.image_thumbnail,
|
|
db_name: delegetedDb.db_name,
|
|
db_slug: delegetedDb.db_slug,
|
|
db_full_name: delegetedDb.db_full_name,
|
|
db_image: delegetedDb.db_image,
|
|
db_description: delegetedDb.db_description,
|
|
date_created: delegetedDb.date_created,
|
|
user_priviledge: user_priviledge
|
|
});
|
|
}
|
|
}
|
|
}
|
|
////////////////////////////////////////
|
|
res.json({
|
|
success: true,
|
|
databases: databasesArray
|
|
});
|
|
////////////////////////////////////////
|
|
}
|
|
|
|
|
|
/***/ })
|
|
|
|
};
|
|
;
|
|
|
|
// 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], () => (__webpack_exec__(3990)));
|
|
module.exports = __webpack_exports__;
|
|
|
|
})(); |