updates
This commit is contained in:
@@ -48,12 +48,22 @@ const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT || "";
|
||||
*
|
||||
* @returns { Promise<FunctionReturn> }
|
||||
*/
|
||||
async function localGoogleAuth({ dbSchema, token, clientId, response, additionalFields }) {
|
||||
async function localGoogleAuth({
|
||||
dbSchema,
|
||||
token,
|
||||
clientId,
|
||||
response,
|
||||
additionalFields,
|
||||
}) {
|
||||
/**
|
||||
* Send Response
|
||||
*
|
||||
* @description Send a boolean response
|
||||
*/
|
||||
const scheme = process.env.DSQL_HTTP_SCHEME;
|
||||
const localHost = process.env.DSQL_LOCAL_HOST;
|
||||
const localHostPort = process.env.DSQL_LOCAL_HOST_PORT;
|
||||
|
||||
try {
|
||||
/**
|
||||
* Grab User data
|
||||
@@ -63,7 +73,7 @@ async function localGoogleAuth({ dbSchema, token, clientId, response, additional
|
||||
*/
|
||||
const payloadResponse = await httpsRequest({
|
||||
method: "POST",
|
||||
hostname: "datasquirel.com",
|
||||
hostname: localHost || "datasquirel.com",
|
||||
path: "/user/grab-google-user-from-token",
|
||||
body: {
|
||||
token: token,
|
||||
@@ -114,7 +124,8 @@ async function localGoogleAuth({ dbSchema, token, clientId, response, additional
|
||||
};
|
||||
}
|
||||
|
||||
const { given_name, family_name, email, sub, picture, email_verified } = payload;
|
||||
const { given_name, family_name, email, sub, picture, email_verified } =
|
||||
payload;
|
||||
|
||||
const payloadObject = {
|
||||
email: email || "",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* ==============================================================================
|
||||
*/
|
||||
const https = require("https");
|
||||
const http = require("http");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -27,14 +28,18 @@ const https = require("https");
|
||||
function httpsRequest({ url, method, hostname, path, href, headers, body }) {
|
||||
const reqPayloadString = body ? JSON.stringify(body) : null;
|
||||
|
||||
const scheme = process.env.DSQL_HTTP_SCHEME;
|
||||
const localHost = process.env.DSQL_LOCAL_HOST;
|
||||
const localHostPort = process.env.DSQL_LOCAL_HOST_PORT;
|
||||
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
|
||||
let requestOptions = {
|
||||
method: method,
|
||||
hostname: hostname,
|
||||
port: 443,
|
||||
hostname: localHost || hostname,
|
||||
port: localHostPort || 443,
|
||||
headers: {},
|
||||
};
|
||||
|
||||
@@ -44,7 +49,9 @@ function httpsRequest({ url, method, hostname, path, href, headers, body }) {
|
||||
if (headers) requestOptions.headers = headers;
|
||||
if (body) {
|
||||
requestOptions.headers["Content-Type"] = "application/json";
|
||||
requestOptions.headers["Content-Length"] = Buffer.from(reqPayloadString || "").length;
|
||||
requestOptions.headers["Content-Length"] = Buffer.from(
|
||||
reqPayloadString || ""
|
||||
).length;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
@@ -52,7 +59,7 @@ function httpsRequest({ url, method, hostname, path, href, headers, body }) {
|
||||
////////////////////////////////////////////////
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
const httpsRequest = https.request(
|
||||
const httpsRequest = (scheme?.match(/^http$/i) ? http : https).request(
|
||||
/* ====== Request Options object ====== */
|
||||
// @ts-ignore
|
||||
url ? url : requestOptions,
|
||||
|
||||
Reference in New Issue
Block a user