Updates
This commit is contained in:
@@ -7,6 +7,10 @@ exports.checkAuthFile = exports.deleteAuthFile = exports.getAuthFile = exports.c
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const ejson_1 = __importDefault(require("../../../utils/ejson"));
|
||||
const debug_log_1 = __importDefault(require("../../../utils/logging/debug-log"));
|
||||
function debugFn(log, label) {
|
||||
(0, debug_log_1.default)({ log, addTime: true, title: "write-auth-files", label });
|
||||
}
|
||||
const grabAuthDirs = () => {
|
||||
const DSQL_AUTH_DIR = process.env.DSQL_AUTH_DIR;
|
||||
const ROOT_DIR = (DSQL_AUTH_DIR === null || DSQL_AUTH_DIR === void 0 ? void 0 : DSQL_AUTH_DIR.match(/./))
|
||||
@@ -39,14 +43,14 @@ exports.initAuthFiles = initAuthFiles;
|
||||
const writeAuthFile = (name, data, cleanup) => {
|
||||
(0, exports.initAuthFiles)();
|
||||
try {
|
||||
const { auth, root } = (0, exports.grabAuthDirs)();
|
||||
const { auth } = (0, exports.grabAuthDirs)();
|
||||
if (cleanup) {
|
||||
(0, exports.cleanupUserAuthFiles)(cleanup.userId);
|
||||
}
|
||||
fs_1.default.writeFileSync(path_1.default.join(auth, name), data);
|
||||
return true;
|
||||
}
|
||||
catch ( /** @type {any} */error) {
|
||||
catch (error) {
|
||||
console.log(`Error writing Auth File: ${error.message}`);
|
||||
return false;
|
||||
}
|
||||
@@ -87,7 +91,7 @@ const getAuthFile = (name) => {
|
||||
const authFilePath = path_1.default.join((0, exports.grabAuthDirs)().auth, name);
|
||||
return fs_1.default.readFileSync(authFilePath, "utf-8");
|
||||
}
|
||||
catch ( /** @type {any} */error) {
|
||||
catch (error) {
|
||||
console.log(`Error getting Auth File: ${error.message}`);
|
||||
return null;
|
||||
}
|
||||
@@ -101,7 +105,7 @@ const deleteAuthFile = (name) => {
|
||||
try {
|
||||
return fs_1.default.rmSync(path_1.default.join((0, exports.grabAuthDirs)().auth, name));
|
||||
}
|
||||
catch ( /** @type {any} */error) {
|
||||
catch (error) {
|
||||
console.log(`Error deleting Auth File: ${error.message}`);
|
||||
return null;
|
||||
}
|
||||
@@ -116,7 +120,7 @@ const checkAuthFile = (name) => {
|
||||
return fs_1.default.existsSync(path_1.default.join((0, exports.grabAuthDirs)().auth, name));
|
||||
return true;
|
||||
}
|
||||
catch ( /** @type {any} */error) {
|
||||
catch (error) {
|
||||
console.log(`Error checking Auth File: ${error.message}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user