Updates
This commit is contained in:
parent
3dd1d08a5b
commit
fdd3913f4f
@ -24,7 +24,8 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../backend/varDatabas
|
||||
function loginSocialUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ user, social_platform, invitation, database, additionalFields, useLocal, }) {
|
||||
const finalDbName = database ? database : "datasquirel";
|
||||
const foundUserQuery = `SELECT * FROM \`${finalDbName}\`.\`users\` WHERE email=? AND social_id=? AND social_platform=?`;
|
||||
const dbAppend = database ? `\`${finalDbName}\`.` : "";
|
||||
const foundUserQuery = `SELECT * FROM ${dbAppend}\`users\` WHERE email=? AND social_id=? AND social_platform=?`;
|
||||
const foundUserValues = [user.email, user.social_id, social_platform];
|
||||
const foundUser = yield (0, varDatabaseDbHandler_1.default)({
|
||||
database: finalDbName,
|
||||
@ -40,7 +41,6 @@ function loginSocialUser(_a) {
|
||||
let csrfKey = Math.random().toString(36).substring(2) +
|
||||
"-" +
|
||||
Math.random().toString(36).substring(2);
|
||||
/** @type {import("../../../types").DATASQUIREL_LoggedInUser} */
|
||||
let userPayload = {
|
||||
id: foundUser[0].id,
|
||||
first_name: foundUser[0].first_name,
|
||||
@ -70,7 +70,6 @@ function loginSocialUser(_a) {
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
/** @type {import("../../../types").APILoginFunctionReturn} */
|
||||
let result = {
|
||||
success: true,
|
||||
payload: userPayload,
|
||||
|
@ -60,7 +60,6 @@ function apiGoogleLogin(_a) {
|
||||
* @description Create new user folder and file
|
||||
*/
|
||||
const { given_name, family_name, email, sub, picture } = gUser;
|
||||
/** @type {Object<string, any>} */
|
||||
let payloadObject = {
|
||||
email: email,
|
||||
first_name: given_name,
|
||||
|
@ -22,7 +22,7 @@ const conn_db_handler_1 = __importDefault(require("../../utils/db/conn-db-handle
|
||||
*/
|
||||
function varDatabaseDbHandler(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, queryValuesArray, database, tableSchema, useLocal, debug, }) {
|
||||
let CONNECTION = (0, grab_dsql_connection_1.default)({ fa: true });
|
||||
let CONNECTION = (0, grab_dsql_connection_1.default)({ fa: true, local: useLocal });
|
||||
if (useLocal)
|
||||
CONNECTION = (0, grab_dsql_connection_1.default)({ local: true });
|
||||
if (database === null || database === void 0 ? void 0 : database.match(/^datasquirel$/))
|
||||
|
@ -9,8 +9,25 @@ const serverless_mysql_1 = __importDefault(require("serverless-mysql"));
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
function grabDSQLConnection(param) {
|
||||
if (param === null || param === void 0 ? void 0 : param.local) {
|
||||
return (global.DSQL_DB_CONN ||
|
||||
(0, serverless_mysql_1.default)({
|
||||
config: {
|
||||
host: process.env.DSQL_DB_HOST,
|
||||
user: process.env.DSQL_DB_USERNAME,
|
||||
password: process.env.DSQL_DB_PASSWORD,
|
||||
database: (param === null || param === void 0 ? void 0 : param.noDb)
|
||||
? undefined
|
||||
: process.env.DSQL_DB_NAME,
|
||||
port: process.env.DSQL_DB_PORT
|
||||
? Number(process.env.DSQL_DB_PORT)
|
||||
: undefined,
|
||||
charset: "utf8mb4",
|
||||
},
|
||||
}));
|
||||
}
|
||||
if (param === null || param === void 0 ? void 0 : param.ro) {
|
||||
return (DSQL_READ_ONLY_DB_CONN ||
|
||||
return (global.DSQL_READ_ONLY_DB_CONN ||
|
||||
(0, serverless_mysql_1.default)({
|
||||
config: {
|
||||
host: process.env.DSQL_DB_HOST,
|
||||
|
1
dist/users/social/google-auth.js
vendored
1
dist/users/social/google-auth.js
vendored
@ -59,7 +59,6 @@ function googleAuth(_a) {
|
||||
/**
|
||||
* Initialize HTTP response variable
|
||||
*/
|
||||
/** @type {import("../../package-shared/types").APILoginFunctionReturn} */
|
||||
let httpResponse = {
|
||||
success: false,
|
||||
};
|
||||
|
@ -1,6 +1,9 @@
|
||||
import addAdminUserOnLogin from "../../backend/addAdminUserOnLogin";
|
||||
import varDatabaseDbHandler from "../../backend/varDatabaseDbHandler";
|
||||
import { APILoginFunctionReturn } from "../../../types";
|
||||
import {
|
||||
APILoginFunctionReturn,
|
||||
DATASQUIREL_LoggedInUser,
|
||||
} from "../../../types";
|
||||
|
||||
type Param = {
|
||||
user: {
|
||||
@ -31,8 +34,9 @@ export default async function loginSocialUser({
|
||||
useLocal,
|
||||
}: Param): Promise<APILoginFunctionReturn> {
|
||||
const finalDbName = database ? database : "datasquirel";
|
||||
const dbAppend = database ? `\`${finalDbName}\`.` : "";
|
||||
|
||||
const foundUserQuery = `SELECT * FROM \`${finalDbName}\`.\`users\` WHERE email=? AND social_id=? AND social_platform=?`;
|
||||
const foundUserQuery = `SELECT * FROM ${dbAppend}\`users\` WHERE email=? AND social_id=? AND social_platform=?`;
|
||||
const foundUserValues = [user.email, user.social_id, social_platform];
|
||||
|
||||
const foundUser = await varDatabaseDbHandler({
|
||||
@ -53,8 +57,7 @@ export default async function loginSocialUser({
|
||||
"-" +
|
||||
Math.random().toString(36).substring(2);
|
||||
|
||||
/** @type {import("../../../types").DATASQUIREL_LoggedInUser} */
|
||||
let userPayload: import("../../../types").DATASQUIREL_LoggedInUser = {
|
||||
let userPayload: DATASQUIREL_LoggedInUser = {
|
||||
id: foundUser[0].id,
|
||||
first_name: foundUser[0].first_name,
|
||||
last_name: foundUser[0].last_name,
|
||||
@ -86,8 +89,7 @@ export default async function loginSocialUser({
|
||||
});
|
||||
}
|
||||
|
||||
/** @type {import("../../../types").APILoginFunctionReturn} */
|
||||
let result: import("../../../types").APILoginFunctionReturn = {
|
||||
let result: APILoginFunctionReturn = {
|
||||
success: true,
|
||||
payload: userPayload,
|
||||
csrf: csrfKey,
|
||||
|
@ -65,7 +65,6 @@ export default async function apiGoogleLogin({
|
||||
|
||||
const { given_name, family_name, email, sub, picture } = gUser;
|
||||
|
||||
/** @type {Object<string, any>} */
|
||||
let payloadObject: { [s: string]: any } = {
|
||||
email: email,
|
||||
first_name: given_name,
|
||||
|
@ -23,7 +23,7 @@ export default async function varDatabaseDbHandler({
|
||||
useLocal,
|
||||
debug,
|
||||
}: Param): Promise<any> {
|
||||
let CONNECTION = grabDSQLConnection({ fa: true });
|
||||
let CONNECTION = grabDSQLConnection({ fa: true, local: useLocal });
|
||||
if (useLocal) CONNECTION = grabDSQLConnection({ local: true });
|
||||
if (database?.match(/^datasquirel$/)) CONNECTION = grabDSQLConnection();
|
||||
|
||||
|
@ -23,9 +23,29 @@ type Param = {
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
export default function grabDSQLConnection(param?: Param): ServerlessMysql {
|
||||
if (param?.local) {
|
||||
return (
|
||||
global.DSQL_DB_CONN ||
|
||||
mysql({
|
||||
config: {
|
||||
host: process.env.DSQL_DB_HOST,
|
||||
user: process.env.DSQL_DB_USERNAME,
|
||||
password: process.env.DSQL_DB_PASSWORD,
|
||||
database: param?.noDb
|
||||
? undefined
|
||||
: process.env.DSQL_DB_NAME,
|
||||
port: process.env.DSQL_DB_PORT
|
||||
? Number(process.env.DSQL_DB_PORT)
|
||||
: undefined,
|
||||
charset: "utf8mb4",
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (param?.ro) {
|
||||
return (
|
||||
DSQL_READ_ONLY_DB_CONN ||
|
||||
global.DSQL_READ_ONLY_DB_CONN ||
|
||||
mysql({
|
||||
config: {
|
||||
host: process.env.DSQL_DB_HOST,
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/datasquirel",
|
||||
"version": "3.7.4",
|
||||
"version": "3.7.5",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
@ -77,11 +77,9 @@ export default async function googleAuth({
|
||||
* Initialize HTTP response variable
|
||||
*/
|
||||
|
||||
/** @type {import("../../package-shared/types").APILoginFunctionReturn} */
|
||||
let httpResponse: import("../../package-shared/types").APILoginFunctionReturn =
|
||||
{
|
||||
success: false,
|
||||
};
|
||||
let httpResponse: APILoginFunctionReturn = {
|
||||
success: false,
|
||||
};
|
||||
|
||||
/**
|
||||
* Check for local DB settings
|
||||
|
Loading…
Reference in New Issue
Block a user