Updates
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
GetReturn,
|
||||
} from "../types";
|
||||
import apiGetGrabQueryAndValues from "../utils/grab-query-and-values";
|
||||
import debugLog from "../utils/logging/debug-log";
|
||||
|
||||
type Param<T extends { [k: string]: any } = { [k: string]: any }> = {
|
||||
key?: string;
|
||||
@@ -43,6 +44,10 @@ export default async function get<
|
||||
const grabedHostNames = grabHostNames();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
|
||||
function debugFn(log: any, label?: string) {
|
||||
debugLog({ log, addTime: true, title: "apiGet", label });
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for local DB settings
|
||||
*
|
||||
@@ -62,7 +67,7 @@ export default async function get<
|
||||
} catch (error) {}
|
||||
|
||||
if (debug) {
|
||||
console.log("apiGet:Running Locally ...");
|
||||
debugFn("Running Locally ...");
|
||||
}
|
||||
|
||||
return await apiGet({
|
||||
@@ -96,13 +101,13 @@ export default async function get<
|
||||
};
|
||||
|
||||
if (debug) {
|
||||
console.log("apiGet:queryObject", queryObject);
|
||||
debugFn(queryObject, "queryObject");
|
||||
}
|
||||
|
||||
const queryString = serializeQuery({ ...queryObject });
|
||||
|
||||
if (debug) {
|
||||
console.log("apiGet:queryString", queryString);
|
||||
debugFn(queryString, "queryString");
|
||||
}
|
||||
|
||||
let path = `/api/query/${
|
||||
@@ -110,7 +115,7 @@ export default async function get<
|
||||
}/get${queryString}`;
|
||||
|
||||
if (debug) {
|
||||
console.log("apiGet:path", path);
|
||||
debugFn(path, "path");
|
||||
}
|
||||
|
||||
const requestObject: https.RequestOptions = {
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
DSQL_DatabaseSchemaType,
|
||||
PackageUserLoginRequestBody,
|
||||
} from "../../types";
|
||||
import debugLog from "../../utils/logging/debug-log";
|
||||
|
||||
type Param = {
|
||||
key?: string;
|
||||
@@ -73,6 +74,10 @@ export default async function loginUser({
|
||||
const finalEncryptionSalt =
|
||||
encryptionSalt || process.env.DSQL_ENCRYPTION_SALT;
|
||||
|
||||
function debugFn(log: any, label?: string) {
|
||||
debugLog({ log, addTime: true, title: "loginUser", label });
|
||||
}
|
||||
|
||||
if (!finalEncryptionKey?.match(/.{8,}/)) {
|
||||
console.log("Encryption key is invalid");
|
||||
return {
|
||||
@@ -81,6 +86,7 @@ export default async function loginUser({
|
||||
msg: "Encryption key is invalid",
|
||||
};
|
||||
}
|
||||
|
||||
if (!finalEncryptionSalt?.match(/.{8,}/)) {
|
||||
console.log("Encryption salt is invalid");
|
||||
return {
|
||||
@@ -210,7 +216,7 @@ export default async function loginUser({
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
console.log(`loginUser:httpResponse:`, httpResponse);
|
||||
debugFn(httpResponse, "httpResponse");
|
||||
}
|
||||
|
||||
if (httpResponse?.success) {
|
||||
@@ -244,9 +250,9 @@ export default async function loginUser({
|
||||
const csrfName = cookieNames.csrfCookieName;
|
||||
|
||||
if (debug) {
|
||||
console.log(`loginUser:authKeyName:`, authKeyName);
|
||||
console.log(`loginUser:csrfName:`, csrfName);
|
||||
console.log(`loginUser:encryptedPayload:`, encryptedPayload);
|
||||
debugFn(authKeyName, "authKeyName");
|
||||
debugFn(csrfName, "csrfName");
|
||||
debugFn(encryptedPayload, "encryptedPayload");
|
||||
}
|
||||
|
||||
response?.setHeader("Set-Cookie", [
|
||||
@@ -255,7 +261,7 @@ export default async function loginUser({
|
||||
]);
|
||||
|
||||
if (debug) {
|
||||
console.log(`loginUser:Response Sent!`);
|
||||
debugFn("Response Sent!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { deleteAuthFile } from "../../functions/backend/auth/write-auth-files";
|
||||
import parseCookies from "../../utils/backend/parseCookies";
|
||||
import { DATASQUIREL_LoggedInUser } from "../../types";
|
||||
import grabHostNames from "../../utils/grab-host-names";
|
||||
import debugLog from "../../utils/logging/debug-log";
|
||||
|
||||
type Param = {
|
||||
encryptedUserString?: string;
|
||||
@@ -48,8 +49,12 @@ export default function logoutUser({
|
||||
userId: user_id,
|
||||
});
|
||||
|
||||
function debugFn(log: any, label?: string) {
|
||||
debugLog({ log, addTime: true, title: "logoutUser", label });
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
console.log("logoutUser:cookieNames", cookieNames);
|
||||
debugFn(cookieNames, "cookieNames");
|
||||
}
|
||||
|
||||
const authKeyName = cookieNames.keyCookieName;
|
||||
@@ -84,7 +89,7 @@ export default function logoutUser({
|
||||
})();
|
||||
|
||||
if (debug) {
|
||||
console.log("logoutUser:decryptedUserJSON", decryptedUserJSON);
|
||||
debugFn(decryptedUserJSON, "decryptedUserJSON");
|
||||
}
|
||||
|
||||
if (!decryptedUserJSON) throw new Error("Invalid User");
|
||||
|
||||
Reference in New Issue
Block a user