Bugfix
This commit is contained in:
@@ -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__;
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user