Updates
This commit is contained in:
@@ -4,7 +4,7 @@ const fs = require("fs");
|
||||
const decrypt = require("../dsql/decrypt");
|
||||
|
||||
/** @type {import("../../types").CheckApiCredentialsFn} */
|
||||
const grabApiCred = ({ key, database, table, user_id }) => {
|
||||
const grabApiCred = ({ key, database, table, user_id, media }) => {
|
||||
if (!key) return null;
|
||||
if (!user_id) return null;
|
||||
|
||||
@@ -27,6 +27,8 @@ const grabApiCred = ({ key, database, table, user_id }) => {
|
||||
|
||||
if (!isApiKeyValid) return null;
|
||||
if (!ApiObject.target_database) return ApiObject;
|
||||
if (media) return ApiObject;
|
||||
|
||||
if (!database && ApiObject.target_database) return null;
|
||||
const isDatabaseAllowed = ApiObject.target_database
|
||||
?.split(",")
|
||||
@@ -41,7 +43,7 @@ const grabApiCred = ({ key, database, table, user_id }) => {
|
||||
return null;
|
||||
} catch (/** @type {any} */ error) {
|
||||
console.log(`api-cred ERROR: ${error.message}`);
|
||||
return null;
|
||||
return { error: `api-cred ERROR: ${error.message}` };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ function sqlGenerator({ tableName, genObject }) {
|
||||
return str;
|
||||
})();
|
||||
|
||||
if (sqlSearhString) {
|
||||
if (sqlSearhString?.[0] && sqlSearhString.find((str) => str)) {
|
||||
const stringOperator = genObject?.searchOperator || "AND";
|
||||
queryString += ` WHERE ${sqlSearhString.join(` ${stringOperator} `)} `;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user