Updates
This commit is contained in:
@@ -10,14 +10,16 @@ exports.modules = {
|
||||
|
||||
const fs = __webpack_require__(7147);
|
||||
const decrypt = __webpack_require__(5425);
|
||||
/** @type {import("../../types").CheckApiCredentialsFn} */ const grabApiCred = ({ key , database , table })=>{
|
||||
/** @type {import("../../types").CheckApiCredentialsFn} */ const grabApiCred = ({ key , database , table , user_id })=>{
|
||||
if (!key) return null;
|
||||
if (!user_id) return null;
|
||||
try {
|
||||
const allowedKeysPath = process.env.DSQL_API_KEYS_PATH;
|
||||
if (!allowedKeysPath) throw new Error("process.env.DSQL_API_KEYS_PATH variable not found");
|
||||
const ApiJSON = decrypt(key);
|
||||
/** @type {import("../../types").ApiKeyObject} */ const ApiObject = JSON.parse(ApiJSON || "");
|
||||
const isApiKeyValid = fs.existsSync(`${allowedKeysPath}/${ApiObject.sign}`);
|
||||
if (String(ApiObject.user_id) !== String(user_id)) return null;
|
||||
if (!isApiKeyValid) return null;
|
||||
if (!ApiObject.target_database) return ApiObject;
|
||||
if (!database && ApiObject.target_database) return null;
|
||||
|
||||
Reference in New Issue
Block a user