Bugfix
This commit is contained in:
@@ -223,6 +223,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_4__);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1311);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_5__);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1007);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_6__);
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
@@ -237,6 +239,7 @@ const { execSync } = __webpack_require__(2081);
|
||||
|
||||
|
||||
|
||||
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* API handler
|
||||
* ==============================================================================
|
||||
@@ -260,39 +263,25 @@ const { execSync } = __webpack_require__(2081);
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const deletedKeys = fs.readFileSync("./apiKeys/deleted.txt", "utf8");
|
||||
/** @type {string} */ // @ts-ignore
|
||||
*/ /** @type {string} */ // @ts-ignore
|
||||
const authorization = req.headers.authorization;
|
||||
if (deletedKeys.includes(authorization)) {
|
||||
return res.json({
|
||||
success: false,
|
||||
msg: "Key Inactive!"
|
||||
});
|
||||
}
|
||||
const userJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_2___default()(authorization);
|
||||
if (!userJSON) throw new Error("Invalid Credentials");
|
||||
const user = JSON.parse(userJSON);
|
||||
const { user_id , full_access , csrf } = user;
|
||||
if (!full_access || !csrf) return res.json({
|
||||
success: false,
|
||||
msg: "Unauthorized"
|
||||
});
|
||||
/**
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const sanitizedReqBody = req.body;
|
||||
const sanitizedReqBody = req.body;
|
||||
const { payload , database , encryptionKey } = sanitizedReqBody;
|
||||
/**
|
||||
* Hash Password
|
||||
*
|
||||
* @description Hash Password
|
||||
*/ if (!payload?.password) {
|
||||
res.json({
|
||||
success: false,
|
||||
msg: `Password is required to create an account`
|
||||
});
|
||||
return;
|
||||
const apiCred = _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_6___default()({
|
||||
key: authorization,
|
||||
database
|
||||
});
|
||||
if (!apiCred?.user_id) {
|
||||
throw new Error("Api Credentials invalid!");
|
||||
}
|
||||
if (!apiCred.full_access || !apiCred.sign) {
|
||||
if (!payload?.password) {
|
||||
res.json({
|
||||
success: false,
|
||||
msg: `Password is required to create an account`
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
const hashedPassword = datasquirel_functions_hashPassword__WEBPACK_IMPORTED_MODULE_3___default()({
|
||||
encryptionKey: encryptionKey,
|
||||
@@ -307,14 +296,14 @@ const { execSync } = __webpack_require__(2081);
|
||||
* @required - payload.last_name
|
||||
* @required - payload.email
|
||||
* @required - payload.password
|
||||
*/ const dbFullName = `datasquirel_user_${user_id}_${database}`;
|
||||
*/ const dbFullName = `datasquirel_user_${apiCred.user_id}_${database}`;
|
||||
let fields = await _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_5___default()({
|
||||
queryString: `SHOW COLUMNS FROM users`,
|
||||
database: dbFullName
|
||||
});
|
||||
if (!fields) {
|
||||
const newTable = await _functions_backend_addUsersTableToDb__WEBPACK_IMPORTED_MODULE_0___default()({
|
||||
userId: user_id,
|
||||
userId: Number(apiCred.user_id),
|
||||
database: database
|
||||
});
|
||||
fields = await _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_5___default()({
|
||||
@@ -416,7 +405,7 @@ const { execSync } = __webpack_require__(2081);
|
||||
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,8164,7638,9258], () => (__webpack_exec__(1280)));
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2224,2163,3017,3403,7547,5886,5338,8326,1311,1007,8164,7638,9258], () => (__webpack_exec__(1280)));
|
||||
module.exports = __webpack_exports__;
|
||||
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
@@ -84,6 +84,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1311);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1007);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__);
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
@@ -93,6 +95,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
|
||||
|
||||
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* API handler
|
||||
* ==============================================================================
|
||||
@@ -116,20 +119,17 @@ __webpack_require__.r(__webpack_exports__);
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const deletedKeys = fs.readFileSync("./apiKeys/deleted.txt", "utf8");
|
||||
/** @type {string} */ // @ts-ignore
|
||||
*/ /** @type {string} */ // @ts-ignore
|
||||
const authorization = req.headers.authorization;
|
||||
if (deletedKeys.includes(authorization)) {
|
||||
return res.json({
|
||||
success: false,
|
||||
msg: "Key Inactive!"
|
||||
});
|
||||
const { payload , database } = req.body;
|
||||
const apiCred = _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default()({
|
||||
key: authorization,
|
||||
database: database?.db_slug
|
||||
});
|
||||
if (!apiCred?.user_id) {
|
||||
throw new Error("Api Credentials invalid!");
|
||||
}
|
||||
const userJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(authorization);
|
||||
if (!userJSON) throw new Error("Invalid Credentials");
|
||||
const user = JSON.parse(userJSON);
|
||||
const { user_id , full_access , csrf } = user;
|
||||
if (!full_access || !csrf) return res.json({
|
||||
if (!apiCred.full_access || !apiCred.sign) return res.json({
|
||||
success: false,
|
||||
msg: "Unauthorized"
|
||||
});
|
||||
@@ -137,8 +137,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const { payload , database } = req.body;
|
||||
/**
|
||||
*/ /**
|
||||
* Input Validation
|
||||
*
|
||||
* @description Input Validation
|
||||
@@ -147,7 +146,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
* @required - payload.email
|
||||
* @required - payload.username
|
||||
* @required - payload.password
|
||||
*/ const dbFullName = `datasquirel_user_${user_id}_${database}`;
|
||||
*/ const dbFullName = `datasquirel_user_${apiCred.user_id}_${database}`;
|
||||
const deleteUser = await _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_2___default()({
|
||||
queryString: `DELETE FROM users WHERE id='${payload.id}'`,
|
||||
database: dbFullName
|
||||
@@ -182,7 +181,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
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,8326,1311], () => (__webpack_exec__(5134)));
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2224,2163,3017,3403,8326,1311,1007], () => (__webpack_exec__(5134)));
|
||||
module.exports = __webpack_exports__;
|
||||
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
@@ -84,6 +84,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1311);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1007);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__);
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
@@ -93,6 +95,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
|
||||
|
||||
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* API handler
|
||||
* ==============================================================================
|
||||
@@ -110,34 +113,17 @@ __webpack_require__.r(__webpack_exports__);
|
||||
*
|
||||
* @description Send a boolean response
|
||||
*/ try {
|
||||
/**
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const deletedKeys = fs.readFileSync("./apiKeys/deleted.txt", "utf8");
|
||||
/** @type {string} */ // @ts-ignore
|
||||
const authorization = req.headers.authorization;
|
||||
if (deletedKeys.includes(authorization)) {
|
||||
return res.json({
|
||||
success: false,
|
||||
msg: "Key Inactive!"
|
||||
});
|
||||
const { userId , database } = req.body;
|
||||
const apiCred = _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default()({
|
||||
key: authorization,
|
||||
database
|
||||
});
|
||||
if (!apiCred?.user_id) {
|
||||
throw new Error("Api Credentials invalid!");
|
||||
}
|
||||
const userJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(authorization);
|
||||
if (!userJSON) throw new Error("invalid Credentials");
|
||||
const user = JSON.parse(userJSON);
|
||||
const { user_id , full_access , csrf } = user;
|
||||
try {
|
||||
const decryptedCsrfJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(csrf);
|
||||
const decryptedCsrf = decryptedCsrfJSON ? JSON.parse(decryptedCsrfJSON) : null;
|
||||
} catch (/** @type {any} */ error) {
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default()({
|
||||
component: "/api/user/get-user/lines-61-64",
|
||||
message: error.message,
|
||||
user: {}
|
||||
});
|
||||
}
|
||||
if (!full_access || !csrf) return res.json({
|
||||
if (!apiCred.full_access || !apiCred.sign) return res.json({
|
||||
success: false,
|
||||
msg: "Unauthorized"
|
||||
});
|
||||
@@ -147,8 +133,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
* @description Authenticate user
|
||||
*/ const sanitizedReqBody = req.body;
|
||||
const sanitizedFields = sanitizedReqBody.fields.map((/** @type {String} */ fld)=>fld.replace(/[^a-z\_]/g, ""));
|
||||
const { userId , database } = sanitizedReqBody;
|
||||
const dbFullName = `datasquirel_user_${user_id}_${database}`;
|
||||
const dbFullName = `datasquirel_user_${apiCred.user_id}_${database}`;
|
||||
/**
|
||||
* GRAB user
|
||||
*
|
||||
@@ -177,11 +162,11 @@ __webpack_require__.r(__webpack_exports__);
|
||||
payload: foundUser[0]
|
||||
});
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error1) {
|
||||
} catch (/** @type {any} */ error) {
|
||||
////////////////////////////////////////
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default()({
|
||||
component: "/api/user/get-user/main-catch-error",
|
||||
message: error1.message,
|
||||
message: error.message,
|
||||
user: {}
|
||||
});
|
||||
res.json({
|
||||
@@ -202,7 +187,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
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,8326,1311], () => (__webpack_exec__(6636)));
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2224,2163,3017,3403,8326,1311,1007], () => (__webpack_exec__(6636)));
|
||||
module.exports = __webpack_exports__;
|
||||
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
@@ -111,6 +111,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _functions_backend_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var _shell_utils_camelJoinedtoCamelSpace__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2127);
|
||||
/* harmony import */ var _shell_utils_camelJoinedtoCamelSpace__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_shell_utils_camelJoinedtoCamelSpace__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1007);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4__);
|
||||
// @ts-check
|
||||
/**
|
||||
* Imports
|
||||
@@ -120,6 +122,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
|
||||
|
||||
|
||||
const githubLogin = __webpack_require__(6069);
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* API handler
|
||||
@@ -143,27 +146,16 @@ const githubLogin = __webpack_require__(6069);
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const deletedKeys = fs.readFileSync("./apiKeys/deleted.txt", "utf8");
|
||||
*/ const { code , email , clientId , clientSecret , database , additionalFields , } = req.body;
|
||||
const authorization = req.headers.authorization || "";
|
||||
if (deletedKeys.includes(authorization)) {
|
||||
return res.json({
|
||||
success: false,
|
||||
msg: "Key Inactive!"
|
||||
});
|
||||
const apiCred = _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4___default()({
|
||||
key: authorization,
|
||||
database
|
||||
});
|
||||
if (!apiCred?.user_id) {
|
||||
throw new Error("Api Credentials invalid!");
|
||||
}
|
||||
const userJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(authorization);
|
||||
const user = userJSON ? JSON.parse(userJSON) : null;
|
||||
const { user_id , full_access , csrf } = user;
|
||||
try {
|
||||
const decryptedCsrfJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(csrf);
|
||||
const decryptedCsrf = decryptedCsrfJSON ? JSON.parse(decryptedCsrfJSON) : null;
|
||||
} catch (/** @type {any} */ error) {
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default()({
|
||||
component: "/api/user/google-login",
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
if (!full_access || !csrf) return res.json({
|
||||
if (!apiCred.full_access || !apiCred.sign) return res.json({
|
||||
success: false,
|
||||
msg: "Unauthorized"
|
||||
});
|
||||
@@ -171,8 +163,7 @@ const githubLogin = __webpack_require__(6069);
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const { code , email , clientId , clientSecret , database , additionalFields , } = req.body;
|
||||
if (!code || !clientId || !clientSecret || !database) {
|
||||
*/ if (!code || !clientId || !clientSecret || !database) {
|
||||
return res.json({
|
||||
success: false,
|
||||
msg: "Missing query params"
|
||||
@@ -199,7 +190,7 @@ const githubLogin = __webpack_require__(6069);
|
||||
msg: "No github user returned"
|
||||
});
|
||||
}
|
||||
const targetDbName = `datasquirel_user_${user_id}_${database}`;
|
||||
const targetDbName = `datasquirel_user_${apiCred.user_id}_${database}`;
|
||||
const socialId = gitHubUser.name || gitHubUser.id || gitHubUser.login;
|
||||
const targetName = gitHubUser.name || gitHubUser.login;
|
||||
const nameArray = targetName?.match(/ /) ? targetName?.split(" ") : targetName?.match(/\-/) ? targetName?.split("-") : [
|
||||
@@ -236,15 +227,15 @@ const githubLogin = __webpack_require__(6069);
|
||||
////////////////////////////////////////////////
|
||||
res.json({
|
||||
...loggedInGithubUser,
|
||||
dsqlUserId: user_id
|
||||
dsqlUserId: apiCred.user_id
|
||||
});
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error1) {
|
||||
} catch (/** @type {any} */ error) {
|
||||
////////////////////////////////////////
|
||||
console.log("ERROR in 'github-auth' API route =>", error1.message);
|
||||
console.log("ERROR in 'github-auth' API route =>", error.message);
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default()({
|
||||
component: "/api/social-login/github-auth/catch-error",
|
||||
message: error1.message
|
||||
message: error.message
|
||||
});
|
||||
res.json({
|
||||
success: false,
|
||||
@@ -267,7 +258,7 @@ const githubLogin = __webpack_require__(6069);
|
||||
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__(7911)));
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2224,2163,3017,3403,7547,5886,5338,8326,1311,1007,6926,7487,613,4294,6968,722,9971], () => (__webpack_exec__(7911)));
|
||||
module.exports = __webpack_exports__;
|
||||
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
@@ -102,6 +102,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _functions_backend_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7839);
|
||||
/* harmony import */ var _functions_backend_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1007);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__);
|
||||
// @ts-check
|
||||
/** # MODULE TRACE
|
||||
======================================================================
|
||||
@@ -115,6 +117,7 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
|
||||
|
||||
|
||||
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* API handler
|
||||
* ==============================================================================
|
||||
@@ -133,28 +136,16 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
*
|
||||
* @description Send a boolean response
|
||||
*/ try {
|
||||
/**
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const deletedKeys = fs.readFileSync("./apiKeys/deleted.txt", "utf8");
|
||||
/** @type {string} */ // @ts-ignore
|
||||
const { token , clientId , database , additionalFields } = req.body;
|
||||
const authorization = req.headers.authorization;
|
||||
if (deletedKeys.includes(authorization)) {
|
||||
return res.json({
|
||||
success: false,
|
||||
msg: "Key Inactive!"
|
||||
});
|
||||
const apiCred = _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default()({
|
||||
key: authorization,
|
||||
database
|
||||
});
|
||||
if (!apiCred?.user_id) {
|
||||
throw new Error("Api Credentials invalid!");
|
||||
}
|
||||
const userJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(authorization);
|
||||
if (!userJSON) throw new Error("Failed!");
|
||||
const user = JSON.parse(userJSON);
|
||||
const { user_id , full_access , csrf } = user;
|
||||
try {
|
||||
const decryptedCsrfJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(csrf);
|
||||
const decryptedCsrf = JSON.parse(decryptedCsrfJSON || "{}");
|
||||
} catch (error) {}
|
||||
if (!full_access || !csrf) return res.json({
|
||||
if (!apiCred.full_access || !apiCred.sign) return res.json({
|
||||
success: false,
|
||||
msg: "Unauthorized"
|
||||
});
|
||||
@@ -165,8 +156,7 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
* Grab User data
|
||||
*
|
||||
* @description Grab User data
|
||||
*/ const { token , clientId , database , additionalFields } = req.body;
|
||||
const client = new OAuth2Client(clientId);
|
||||
*/ const client = new OAuth2Client(clientId);
|
||||
const ticket = await client.verifyIdToken({
|
||||
idToken: token,
|
||||
audience: clientId
|
||||
@@ -196,7 +186,7 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
* Create new user folder and file
|
||||
*
|
||||
* @description Create new user folder and file
|
||||
*/ const targetDbName = `datasquirel_user_${user_id}_${database}`;
|
||||
*/ const targetDbName = `datasquirel_user_${apiCred.user_id}_${database}`;
|
||||
const { given_name , family_name , email , sub , picture , email_verified } = payload;
|
||||
const payloadObject = {
|
||||
email: email,
|
||||
@@ -228,14 +218,14 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
////////////////////////////////////////
|
||||
res.json({
|
||||
...loggedInGoogleUser,
|
||||
dsqlUserId: user_id
|
||||
dsqlUserId: apiCred.user_id
|
||||
});
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error1) {
|
||||
} catch (/** @type {any} */ error) {
|
||||
////////////////////////////////////////
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default()({
|
||||
component: "/api/user/google-login/main-catch-error",
|
||||
message: error1.message,
|
||||
message: error.message,
|
||||
user: {}
|
||||
});
|
||||
res.json({
|
||||
@@ -256,7 +246,7 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
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], () => (__webpack_exec__(3364)));
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2224,2163,3017,3403,7547,5886,5338,8326,1311,1007,6926,7487,613,4294,6968], () => (__webpack_exec__(3364)));
|
||||
module.exports = __webpack_exports__;
|
||||
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
@@ -75,6 +75,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2163);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1007);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_2__);
|
||||
// @ts-check
|
||||
/** # MODULE TRACE
|
||||
======================================================================
|
||||
@@ -87,6 +89,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
const { OAuth2Client } = __webpack_require__(6781);
|
||||
|
||||
|
||||
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* @type {import("next").NextApiHandler}
|
||||
*/ async function handler(req, res) {
|
||||
@@ -108,25 +111,15 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const deletedKeys = fs.readFileSync("./apiKeys/deleted.txt", "utf8");
|
||||
/** @type {string} */ // @ts-ignore
|
||||
*/ /** @type {string} */ // @ts-ignore
|
||||
const authorization = req.headers.authorization;
|
||||
if (deletedKeys.includes(authorization)) {
|
||||
return res.json({
|
||||
success: false,
|
||||
payload: null,
|
||||
msg: "Key Inactive!"
|
||||
});
|
||||
const apiCred = _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_2___default()({
|
||||
key: authorization
|
||||
});
|
||||
if (!apiCred?.user_id) {
|
||||
throw new Error("Api Credentials invalid!");
|
||||
}
|
||||
const userJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(authorization);
|
||||
if (!userJSON) throw new Error("Failed!");
|
||||
const user = JSON.parse(userJSON);
|
||||
const { user_id , full_access , csrf } = user;
|
||||
try {
|
||||
const decryptedCsrfJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(csrf);
|
||||
const decryptedCsrf = JSON.parse(decryptedCsrfJSON || "");
|
||||
} catch (error) {}
|
||||
if (!full_access || !csrf) return res.json({
|
||||
if (!apiCred.full_access || !apiCred.sign) return res.json({
|
||||
success: false,
|
||||
payload: null,
|
||||
msg: "Unauthorized"
|
||||
@@ -160,11 +153,11 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
payload
|
||||
});
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error1) {
|
||||
} catch (/** @type {any} */ error) {
|
||||
////////////////////////////////////////
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default()({
|
||||
component: "/api/user/grab-google-user-from-token/main-catch-error",
|
||||
message: error1.message
|
||||
message: error.message
|
||||
});
|
||||
res.json({
|
||||
success: false,
|
||||
@@ -185,7 +178,7 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
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, [2163], () => (__webpack_exec__(4606)));
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2163,1007], () => (__webpack_exec__(4606)));
|
||||
module.exports = __webpack_exports__;
|
||||
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
@@ -93,6 +93,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1311);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1007);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4__);
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
@@ -103,6 +105,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
|
||||
|
||||
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* API handler
|
||||
* ==============================================================================
|
||||
@@ -120,34 +123,17 @@ __webpack_require__.r(__webpack_exports__);
|
||||
*
|
||||
* @description Send a boolean response
|
||||
*/ try {
|
||||
/**
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const deletedKeys = fs.readFileSync("./apiKeys/deleted.txt", "utf8");
|
||||
/** @type {string} */ // @ts-ignore
|
||||
/** @type {import("@/package-shared/types").PackageUserLoginRequestBody} */ const reqBody = req.body;
|
||||
const { encryptionKey , payload , database , additionalFields , email_login , email_login_code , email_login_field , token , } = reqBody;
|
||||
const authorization = req.headers.authorization;
|
||||
if (deletedKeys.includes(authorization)) {
|
||||
return res.json({
|
||||
success: false,
|
||||
msg: "Key Inactive!"
|
||||
});
|
||||
const apiCred = _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4___default()({
|
||||
key: authorization,
|
||||
database
|
||||
});
|
||||
if (!apiCred?.user_id) {
|
||||
throw new Error("Api Credentials invalid!");
|
||||
}
|
||||
const userJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_1___default()(authorization);
|
||||
if (!userJSON) throw new Error("Failed!");
|
||||
const user = JSON.parse(userJSON);
|
||||
const { user_id , full_access , csrf } = user;
|
||||
try {
|
||||
const decryptedCsrfJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_1___default()(csrf);
|
||||
const decryptedCsrf = JSON.parse(decryptedCsrfJSON || "");
|
||||
} catch (/** @type {any} */ error) {
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_2___default()({
|
||||
component: "/api/user/login-user/lines-61-64",
|
||||
message: error.message,
|
||||
user: {}
|
||||
});
|
||||
}
|
||||
if (!full_access || !csrf) return res.json({
|
||||
if (!apiCred.full_access || !apiCred.sign) return res.json({
|
||||
success: false,
|
||||
msg: "Unauthorized"
|
||||
});
|
||||
@@ -155,12 +141,10 @@ __webpack_require__.r(__webpack_exports__);
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ /** @type {import("@/package-shared/types").PackageUserLoginRequestBody} */ const reqBody = req.body;
|
||||
const { encryptionKey , payload , database , additionalFields , email_login , email_login_code , email_login_field , token , } = reqBody;
|
||||
const email = payload.email;
|
||||
*/ const email = payload.email;
|
||||
const username = payload.username;
|
||||
const password = payload.password;
|
||||
const dbFullName = `datasquirel_user_${user_id}_${database}`;
|
||||
const dbFullName = `datasquirel_user_${apiCred.user_id}_${database}`;
|
||||
/**
|
||||
* Check input validity
|
||||
*
|
||||
@@ -262,7 +246,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
success: true,
|
||||
msg: "Login Successful",
|
||||
payload: userPayload,
|
||||
userId: user_id
|
||||
userId: apiCred.user_id
|
||||
};
|
||||
if (additionalFields && Array.isArray(additionalFields) && additionalFields.length > 0) {
|
||||
additionalFields.forEach((key)=>{
|
||||
@@ -278,11 +262,11 @@ __webpack_require__.r(__webpack_exports__);
|
||||
////////////////////////////////////////
|
||||
/** ********************* Send Response */ res.json(resposeObject);
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error1) {
|
||||
} catch (/** @type {any} */ error) {
|
||||
////////////////////////////////////////
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_2___default()({
|
||||
component: "/api/user/login-user/main-catch-error",
|
||||
message: error1.message,
|
||||
message: error.message,
|
||||
user: {}
|
||||
});
|
||||
res.json({
|
||||
@@ -303,7 +287,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
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,8326,1311], () => (__webpack_exec__(5827)));
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2224,2163,3017,3403,8326,1311,1007], () => (__webpack_exec__(5827)));
|
||||
module.exports = __webpack_exports__;
|
||||
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
@@ -84,6 +84,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1311);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1007);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__);
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
@@ -93,6 +95,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
|
||||
|
||||
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* API handler
|
||||
* ==============================================================================
|
||||
@@ -110,34 +113,18 @@ __webpack_require__.r(__webpack_exports__);
|
||||
*
|
||||
* @description Send a boolean response
|
||||
*/ try {
|
||||
/**
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const deletedKeys = fs.readFileSync("./apiKeys/deleted.txt", "utf8");
|
||||
const reqBody = req.body;
|
||||
/** @type {{ existingUser:import("@/package-shared/types").UserType, database:string, additionalFields?: any}} */ const { existingUser , database , additionalFields } = reqBody;
|
||||
/** @type {string} */ // @ts-ignore
|
||||
const authorization = req.headers.authorization;
|
||||
if (deletedKeys.includes(authorization)) {
|
||||
return res.json({
|
||||
success: false,
|
||||
msg: "Key Inactive!"
|
||||
});
|
||||
const apiCred = _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default()({
|
||||
key: authorization,
|
||||
database
|
||||
});
|
||||
if (!apiCred?.user_id) {
|
||||
throw new Error("Api Credentials invalid!");
|
||||
}
|
||||
const userJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(authorization);
|
||||
if (!userJSON) throw new Error("Failed!");
|
||||
const user = JSON.parse(userJSON);
|
||||
const { user_id , full_access , csrf } = user;
|
||||
try {
|
||||
const decryptedCsrfJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(csrf);
|
||||
const decryptedCsrf = JSON.parse(decryptedCsrfJSON || "");
|
||||
} catch (/** @type {any} */ error) {
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default()({
|
||||
component: "/api/user/reauth-user/lines-61-64",
|
||||
message: error.message,
|
||||
user: {}
|
||||
});
|
||||
}
|
||||
if (!full_access || !csrf) return res.json({
|
||||
if (!apiCred.full_access || !apiCred.sign) return res.json({
|
||||
success: false,
|
||||
msg: "Unauthorized"
|
||||
});
|
||||
@@ -145,9 +132,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const reqBody = req.body;
|
||||
/** @type {{ existingUser:import("@/package-shared/types").UserType, database:string, additionalFields?: any}} */ const { existingUser , database , additionalFields } = reqBody;
|
||||
const dbFullName = `datasquirel_user_${user_id}_${database}`;
|
||||
*/ const dbFullName = `datasquirel_user_${apiCred.user_id}_${database}`;
|
||||
/**
|
||||
* GRAB user
|
||||
*
|
||||
@@ -202,14 +187,14 @@ __webpack_require__.r(__webpack_exports__);
|
||||
success: true,
|
||||
msg: "Login Successful",
|
||||
payload: userPayload,
|
||||
userId: user_id
|
||||
userId: apiCred.user_id
|
||||
});
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error1) {
|
||||
} catch (/** @type {any} */ error) {
|
||||
////////////////////////////////////////
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default()({
|
||||
component: "/api/user/reauth-user/main-catch-error",
|
||||
message: error1.message,
|
||||
message: error.message,
|
||||
user: {}
|
||||
});
|
||||
res.json({
|
||||
@@ -230,7 +215,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
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,8326,1311], () => (__webpack_exec__(5231)));
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2224,2163,3017,3403,8326,1311,1007], () => (__webpack_exec__(5231)));
|
||||
module.exports = __webpack_exports__;
|
||||
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
@@ -127,6 +127,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1311);
|
||||
/* harmony import */ var _package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_varDatabaseDbHandler__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1007);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4__);
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
@@ -139,6 +141,7 @@ const path = __webpack_require__(1017);
|
||||
|
||||
|
||||
|
||||
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* API handler
|
||||
* ==============================================================================
|
||||
@@ -156,34 +159,17 @@ const path = __webpack_require__(1017);
|
||||
*
|
||||
* @description Send a boolean response
|
||||
*/ try {
|
||||
/**
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const deletedKeys = fs.readFileSync("./apiKeys/deleted.txt", "utf8");
|
||||
/** @type {string} */ // @ts-ignore
|
||||
const reqBody = req.body;
|
||||
const { email , database , email_login_field , mail_domain , mail_password , mail_username , mail_port , sender , html , } = reqBody;
|
||||
const authorization = req.headers.authorization;
|
||||
if (deletedKeys.includes(authorization)) {
|
||||
return res.json({
|
||||
success: false,
|
||||
msg: "Key Inactive!"
|
||||
});
|
||||
const apiCred = _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_4___default()({
|
||||
key: authorization,
|
||||
database
|
||||
});
|
||||
if (!apiCred?.user_id) {
|
||||
throw new Error("Api Credentials invalid!");
|
||||
}
|
||||
const userJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(authorization);
|
||||
if (!userJSON) throw new Error("Failed!");
|
||||
const user = JSON.parse(userJSON);
|
||||
const { user_id , full_access , csrf } = user;
|
||||
try {
|
||||
const decryptedCsrfJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(csrf);
|
||||
const decryptedCsrf = JSON.parse(decryptedCsrfJSON || "");
|
||||
} catch (/** @type {any} */ error) {
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_2___default()({
|
||||
component: "/api/user/login-user/lines-61-64",
|
||||
message: error.message,
|
||||
user: {}
|
||||
});
|
||||
}
|
||||
if (!full_access || !csrf) return res.json({
|
||||
if (!apiCred.full_access || !apiCred.sign) return res.json({
|
||||
success: false,
|
||||
msg: "Unauthorized"
|
||||
});
|
||||
@@ -191,9 +177,7 @@ const path = __webpack_require__(1017);
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const reqBody = req.body;
|
||||
const { email , database , email_login_field , mail_domain , mail_password , mail_username , mail_port , sender , html , } = reqBody;
|
||||
const dbFullName = `datasquirel_user_${user_id}_${database}`;
|
||||
*/ const dbFullName = `datasquirel_user_${apiCred.user_id}_${database}`;
|
||||
/**
|
||||
* Check input validity
|
||||
*
|
||||
@@ -271,16 +255,16 @@ const path = __webpack_require__(1017);
|
||||
msg: "Success"
|
||||
});
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error1) {
|
||||
} catch (/** @type {any} */ error) {
|
||||
////////////////////////////////////////
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_2___default()({
|
||||
component: "/api/user/login-user/main-catch-error",
|
||||
message: error1.message,
|
||||
message: error.message,
|
||||
user: {}
|
||||
});
|
||||
res.json({
|
||||
success: false,
|
||||
msg: "Failed: " + error1.message
|
||||
msg: "Failed: " + error.message
|
||||
});
|
||||
////////////////////////////////////////
|
||||
}
|
||||
@@ -296,7 +280,7 @@ const path = __webpack_require__(1017);
|
||||
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,8326,1311], () => (__webpack_exec__(9916)));
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2224,2163,3017,3403,8326,1311,1007], () => (__webpack_exec__(9916)));
|
||||
module.exports = __webpack_exports__;
|
||||
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
@@ -91,6 +91,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2163);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1007);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__);
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
@@ -100,6 +102,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
|
||||
|
||||
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* API handler
|
||||
* ==============================================================================
|
||||
@@ -119,32 +122,19 @@ __webpack_require__.r(__webpack_exports__);
|
||||
*
|
||||
* @description Send a boolean response
|
||||
*/ try {
|
||||
/**
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const deletedKeys = fs.readFileSync("./apiKeys/deleted.txt", "utf8");
|
||||
/** @type {string} */ // @ts-ignore
|
||||
const authorization = req.headers.authorization;
|
||||
if (deletedKeys.includes(authorization)) {
|
||||
return res.json({
|
||||
success: false,
|
||||
msg: "Key Inactive!"
|
||||
});
|
||||
const { payload , database } = req.body;
|
||||
const apiCred = _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default()({
|
||||
key: authorization,
|
||||
database
|
||||
});
|
||||
if (!apiCred?.user_id) {
|
||||
throw new Error("Api Credentials invalid!");
|
||||
}
|
||||
const userJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_1___default()(authorization);
|
||||
if (!userJSON) throw new Error("Failed!");
|
||||
const user = JSON.parse(userJSON);
|
||||
const { user_id , full_access , csrf } = user;
|
||||
if (!full_access || !csrf) return res.json({
|
||||
if (!apiCred.full_access || !apiCred.sign) return res.json({
|
||||
success: false,
|
||||
msg: "Unauthorized"
|
||||
});
|
||||
/**
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const { payload , database } = req.body;
|
||||
/**
|
||||
* Input Validation
|
||||
*
|
||||
@@ -154,7 +144,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
* @required - payload.email
|
||||
* @required - payload.username
|
||||
* @required - payload.password
|
||||
*/ const dbFullName = `datasquirel_user_${user_id}_${database}`;
|
||||
*/ const dbFullName = `datasquirel_user_${apiCred.user_id}_${database}`;
|
||||
const data = (()=>{
|
||||
const reqBodyKeys = Object.keys(payload);
|
||||
/** @type {any} */ const finalData = {};
|
||||
@@ -203,7 +193,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
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], () => (__webpack_exec__(7830)));
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2224,2163,3017,3403,7547,5886,1007], () => (__webpack_exec__(7830)));
|
||||
module.exports = __webpack_exports__;
|
||||
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user