Updates
This commit is contained in:
+4
-2
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabDbSSL;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const grab_dir_names_1 = __importDefault(require("./names/grab-dir-names"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
/**
|
||||
* # Grab SSL
|
||||
*/
|
||||
@@ -16,10 +17,11 @@ function grabDbSSL() {
|
||||
maxscaleSSLCaCertFileFinal = maxscaleSSLCaCertFile;
|
||||
}
|
||||
catch (error) { }
|
||||
const caFilePath = process.env.DSQL_SSL_CA_CERT || maxscaleSSLCaCertFileFinal;
|
||||
if (!(caFilePath === null || caFilePath === void 0 ? void 0 : caFilePath.match(/./))) {
|
||||
const caProivdedPath = process.env.DSQL_SSL_CA_CERT || maxscaleSSLCaCertFileFinal;
|
||||
if (!(caProivdedPath === null || caProivdedPath === void 0 ? void 0 : caProivdedPath.match(/./))) {
|
||||
return undefined;
|
||||
}
|
||||
const caFilePath = path_1.default.resolve(process.cwd(), caProivdedPath);
|
||||
if (!fs_1.default.existsSync(caFilePath)) {
|
||||
console.log(`${caFilePath} does not exist`);
|
||||
return undefined;
|
||||
|
||||
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = createUserSQLUser;
|
||||
const generate_password_1 = require("generate-password");
|
||||
const dbHandler_1 = __importDefault(require("../functions/backend/dbHandler"));
|
||||
const crud_1 = __importDefault(require("./data-fetching/crud"));
|
||||
const grab_user_main_sql_user_name_1 = __importDefault(require("./grab-user-main-sql-user-name"));
|
||||
const grab_db_names_1 = __importDefault(require("./grab-db-names"));
|
||||
const handle_mariadb_user_creation_1 = require("../functions/web-app/mariadb-user/handle-mariadb-user-creation");
|
||||
@@ -27,6 +28,20 @@ function createUserSQLUser(user) {
|
||||
noErrorLogs: true,
|
||||
});
|
||||
const newPassword = (0, generate_password_1.generate)({ length: 32 });
|
||||
const updateUser = yield (0, crud_1.default)({
|
||||
action: "update",
|
||||
table: "users",
|
||||
data: {
|
||||
mariadb_host: webHost,
|
||||
mariadb_user: mariaDBUsername,
|
||||
mariadb_pass: newPassword,
|
||||
},
|
||||
targetId: user.id,
|
||||
});
|
||||
if (!updateUser.success) {
|
||||
console.log("updateUser", updateUser);
|
||||
throw new Error(`Couldn't Update Users Table!`);
|
||||
}
|
||||
yield (0, handle_mariadb_user_creation_1.createNewSQLUser)({
|
||||
host: webHost,
|
||||
password: newPassword,
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabDbFullName;
|
||||
const app_names_1 = require("../dict/app-names");
|
||||
const slugify_1 = __importDefault(require("./slugify"));
|
||||
/**
|
||||
* # Grab full database name
|
||||
@@ -19,7 +20,7 @@ function grabDbFullName({ dbName, userId, user, }) {
|
||||
if (!dbName) {
|
||||
return;
|
||||
}
|
||||
const dbNamePrefix = process.env.DSQL_USER_DB_PREFIX;
|
||||
const dbNamePrefix = app_names_1.AppNames["DsqlDbPrefix"];
|
||||
const parsedDbName = (0, slugify_1.default)(dbName, "_");
|
||||
const dbSlug = parsedDbName.replace(new RegExp(`${dbNamePrefix}_?\\d+_`), "");
|
||||
return (0, slugify_1.default)(`${dbNamePrefix}_${finalUserId}_${dbSlug}`, "_");
|
||||
|
||||
Reference in New Issue
Block a user