This commit is contained in:
Benjamin Toby
2025-07-20 07:00:09 +01:00
parent 3437be2c08
commit a429436939
9 changed files with 55 additions and 7 deletions
+5 -2
View File
@@ -1,6 +1,7 @@
import fs from "fs";
import grabDirNames from "./names/grab-dir-names";
import type { ConnectionConfig } from "mariadb";
import path from "path";
type Return = ConnectionConfig["ssl"] | undefined;
@@ -15,13 +16,15 @@ export default function grabDbSSL(): Return {
maxscaleSSLCaCertFileFinal = maxscaleSSLCaCertFile;
} catch (error) {}
const caFilePath =
const caProivdedPath =
process.env.DSQL_SSL_CA_CERT || maxscaleSSLCaCertFileFinal;
if (!caFilePath?.match(/./)) {
if (!caProivdedPath?.match(/./)) {
return undefined;
}
const caFilePath = path.resolve(process.cwd(), caProivdedPath);
if (!fs.existsSync(caFilePath)) {
console.log(`${caFilePath} does not exist`);
return undefined;
@@ -35,6 +35,22 @@ export default async function createUserSQLUser(user: UserType) {
const newPassword = generate({ length: 32 });
const updateUser = await dsqlCrud<DSQL_DATASQUIREL_USERS>({
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!`);
}
await createNewSQLUser({
host: webHost,
password: newPassword,
+2 -1
View File
@@ -1,3 +1,4 @@
import { AppNames } from "../dict/app-names";
import { UserType } from "../types";
import slugify from "./slugify";
@@ -30,7 +31,7 @@ export default function grabDbFullName({
return;
}
const dbNamePrefix = process.env.DSQL_USER_DB_PREFIX;
const dbNamePrefix = AppNames["DsqlDbPrefix"];
const parsedDbName = slugify(dbName, "_");