Updates
This commit is contained in:
@@ -9,9 +9,9 @@ const http = require("http");
|
||||
const https = require("https");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const encrypt = require("../../functions/encrypt");
|
||||
const localGithubAuth = require("../../engine/user/social/github-auth");
|
||||
const encrypt = require("../../package-shared/functions/dsql/encrypt");
|
||||
const grabHostNames = require("../../package-shared/utils/grab-host-names");
|
||||
const apiGithubLogin = require("../../package-shared/functions/api/users/social/api-github-login");
|
||||
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
@@ -168,14 +168,14 @@ async function githubAuth({
|
||||
} catch (error) {}
|
||||
|
||||
if (dbSchema) {
|
||||
httpResponse = await localGithubAuth({
|
||||
dbSchema: dbSchema,
|
||||
httpResponse = await apiGithubLogin({
|
||||
code,
|
||||
email: email || undefined,
|
||||
clientId,
|
||||
clientSecret,
|
||||
additionalFields,
|
||||
res: response,
|
||||
database: DSQL_DB_NAME,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
||||
+14
-16
@@ -9,9 +9,9 @@ const http = require("http");
|
||||
const https = require("https");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const encrypt = require("../../functions/encrypt");
|
||||
const localGoogleAuth = require("../../engine/user/social/google-auth");
|
||||
const encrypt = require("../../package-shared/functions/dsql/encrypt");
|
||||
const grabHostNames = require("../../package-shared/utils/grab-host-names");
|
||||
const apiGoogleLogin = require("../../package-shared/functions/api/users/social/api-google-login");
|
||||
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
@@ -44,6 +44,8 @@ const grabHostNames = require("../../package-shared/utils/grab-host-names");
|
||||
* @param {string} params.encryptionSalt - Encryption salt
|
||||
* @param {object} [params.additionalFields] - Additional Fields to be added to the user object
|
||||
* @param {boolean} [params.user_id] - User ID
|
||||
* @param {string | number} [params.apiUserID] - Required for Local
|
||||
* @param {boolean} [params.useLocal] - Whether to use a remote database instead of API
|
||||
*
|
||||
* @returns { Promise<FunctionReturn> }
|
||||
*/
|
||||
@@ -57,6 +59,8 @@ async function googleAuth({
|
||||
encryptionSalt,
|
||||
additionalFields,
|
||||
user_id,
|
||||
apiUserID,
|
||||
useLocal,
|
||||
}) {
|
||||
const grabedHostNames = grabHostNames();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
@@ -136,21 +140,14 @@ async function googleAuth({
|
||||
*
|
||||
* @description Look for local db settings in `.env` file and by pass the http request if available
|
||||
*/
|
||||
const {
|
||||
DSQL_HOST,
|
||||
DSQL_USER,
|
||||
DSQL_PASS,
|
||||
DSQL_DB_NAME,
|
||||
DSQL_KEY,
|
||||
DSQL_REF_DB_NAME,
|
||||
DSQL_FULL_SYNC,
|
||||
} = process.env;
|
||||
const { DSQL_HOST, DSQL_USER, DSQL_PASS, DSQL_DB_NAME } = process.env;
|
||||
|
||||
if (
|
||||
DSQL_HOST?.match(/./) &&
|
||||
DSQL_USER?.match(/./) &&
|
||||
DSQL_PASS?.match(/./) &&
|
||||
DSQL_DB_NAME?.match(/./)
|
||||
DSQL_DB_NAME?.match(/./) &&
|
||||
useLocal
|
||||
) {
|
||||
/** @type {import("../../package-shared/types").DSQL_DatabaseSchemaType | undefined | undefined} */
|
||||
let dbSchema;
|
||||
@@ -163,13 +160,14 @@ async function googleAuth({
|
||||
dbSchema = JSON.parse(fs.readFileSync(localDbSchemaPath, "utf8"));
|
||||
} catch (error) {}
|
||||
|
||||
if (dbSchema) {
|
||||
httpResponse = await localGoogleAuth({
|
||||
dbSchema: dbSchema,
|
||||
if (dbSchema && apiUserID) {
|
||||
httpResponse = await apiGoogleLogin({
|
||||
token,
|
||||
clientId,
|
||||
additionalFields,
|
||||
response: response,
|
||||
res: response,
|
||||
database: DSQL_DB_NAME,
|
||||
userId: apiUserID,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user