Bugfixes
This commit is contained in:
parent
0a29973cc7
commit
d279d76246
@ -15,9 +15,6 @@ const updateDbEntry = require("./updateDbEntry");
|
|||||||
* @async
|
* @async
|
||||||
*
|
*
|
||||||
* @param {object} params - An object containing the function parameters.
|
* @param {object} params - An object containing the function parameters.
|
||||||
* @param {("Master" | "Dsql User")} [params.dbContext] - What is the database context? "Master"
|
|
||||||
* or "Dsql User". Defaults to "Master"
|
|
||||||
* @param {("Read Only" | "Full Access")} [params.paradigm] - What is the paradigm for "Dsql User"?
|
|
||||||
* "Read only" or "Full Access"? Defaults to "Read Only"
|
* "Read only" or "Full Access"? Defaults to "Read Only"
|
||||||
* @param {string} params.dbFullName - Database full name
|
* @param {string} params.dbFullName - Database full name
|
||||||
* @param {string} params.tableName - Table name
|
* @param {string} params.tableName - Table name
|
||||||
@ -31,7 +28,7 @@ const updateDbEntry = require("./updateDbEntry");
|
|||||||
*
|
*
|
||||||
* @returns {Promise<*>}
|
* @returns {Promise<*>}
|
||||||
*/
|
*/
|
||||||
async function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt }) {
|
async function addDbEntry({ dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt }) {
|
||||||
/**
|
/**
|
||||||
* Initialize variables
|
* Initialize variables
|
||||||
*/
|
*/
|
||||||
@ -55,8 +52,6 @@ async function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, ta
|
|||||||
return null;
|
return null;
|
||||||
} else if (duplicateValue && duplicateValue[0] && update) {
|
} else if (duplicateValue && duplicateValue[0] && update) {
|
||||||
return await updateDbEntry({
|
return await updateDbEntry({
|
||||||
dbContext,
|
|
||||||
paradigm,
|
|
||||||
dbFullName,
|
dbFullName,
|
||||||
tableName,
|
tableName,
|
||||||
data,
|
data,
|
||||||
@ -90,7 +85,7 @@ async function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, ta
|
|||||||
if (!value) continue;
|
if (!value) continue;
|
||||||
|
|
||||||
if (targetFieldSchema?.encrypted) {
|
if (targetFieldSchema?.encrypted) {
|
||||||
value = await encrypt({ data: value, encryptionKey, encryptionSalt });
|
value = encrypt({ data: value, encryptionKey, encryptionSalt });
|
||||||
console.log("DSQL: Encrypted value =>", value);
|
console.log("DSQL: Encrypted value =>", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +103,6 @@ async function localAddUser({ payload, dbSchema }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const addUser = await addDbEntry({
|
const addUser = await addDbEntry({
|
||||||
dbContext: "Dsql User",
|
|
||||||
paradigm: "Full Access",
|
|
||||||
dbFullName: dbFullName,
|
dbFullName: dbFullName,
|
||||||
tableName: "users",
|
tableName: "users",
|
||||||
data: {
|
data: {
|
||||||
|
@ -72,7 +72,6 @@ const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT || "";
|
|||||||
* username: string,
|
* username: string,
|
||||||
* },
|
* },
|
||||||
* res: http.ServerResponse,
|
* res: http.ServerResponse,
|
||||||
* invitation?: object|null,
|
|
||||||
* supEmail?: string | null,
|
* supEmail?: string | null,
|
||||||
* additionalFields?: object,
|
* additionalFields?: object,
|
||||||
* dbSchema: import("../../../../types/database-schema.td").DSQL_DatabaseSchemaType | undefined
|
* dbSchema: import("../../../../types/database-schema.td").DSQL_DatabaseSchemaType | undefined
|
||||||
@ -80,7 +79,7 @@ const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT || "";
|
|||||||
*
|
*
|
||||||
* @returns {Promise<FunctionReturn>} - Response object
|
* @returns {Promise<FunctionReturn>} - Response object
|
||||||
*/
|
*/
|
||||||
async function handleSocialDb({ social_id, email, social_platform, payload, res, invitation, supEmail, additionalFields, dbSchema }) {
|
async function handleSocialDb({ social_id, email, social_platform, payload, res, supEmail, additionalFields, dbSchema }) {
|
||||||
const tableSchema = dbSchema?.tables.find((tb) => tb?.tableName === "users");
|
const tableSchema = dbSchema?.tables.find((tb) => tb?.tableName === "users");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -127,7 +126,9 @@ async function handleSocialDb({ social_id, email, social_platform, payload, res,
|
|||||||
|
|
||||||
let existingEmailOnly = await varDatabaseDbHandler({
|
let existingEmailOnly = await varDatabaseDbHandler({
|
||||||
database: database ? database : "datasquirel",
|
database: database ? database : "datasquirel",
|
||||||
queryString: `SELECT * FROM users WHERE email='${finalEmail}'`,
|
queryString: `SELECT * FROM users WHERE email = ?`,
|
||||||
|
queryValuesArray: [finalEmail],
|
||||||
|
tableSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (existingEmailOnly && existingEmailOnly[0]) {
|
if (existingEmailOnly && existingEmailOnly[0]) {
|
||||||
@ -162,7 +163,7 @@ async function handleSocialDb({ social_id, email, social_platform, payload, res,
|
|||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
|
|
||||||
const socialHashedPassword = await encrypt({
|
const socialHashedPassword = encrypt({
|
||||||
data: social_id.toString(),
|
data: social_id.toString(),
|
||||||
encryptionKey,
|
encryptionKey,
|
||||||
encryptionSalt,
|
encryptionSalt,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "datasquirel",
|
"name": "datasquirel",
|
||||||
"version": "1.7.4",
|
"version": "1.7.5",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
Loading…
Reference in New Issue
Block a user