Updates
This commit is contained in:
@@ -2,4 +2,4 @@ import { APILoginFunctionReturn, HandleSocialDbFunctionParams } from "../../../t
|
||||
/**
|
||||
* # Handle Social DB
|
||||
*/
|
||||
export default function handleSocialDb({ database, social_id, email, social_platform, payload, invitation, supEmail, additionalFields, useLocal, }: HandleSocialDbFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
export default function handleSocialDb({ database, social_id, email, social_platform, payload, invitation, supEmail, additionalFields, useLocal, debug, }: HandleSocialDbFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
|
||||
@@ -25,22 +25,30 @@ const loginSocialUser_1 = __importDefault(require("./loginSocialUser"));
|
||||
* # Handle Social DB
|
||||
*/
|
||||
function handleSocialDb(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ database, social_id, email, social_platform, payload, invitation, supEmail, additionalFields, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ database, social_id, email, social_platform, payload, invitation, supEmail, additionalFields, useLocal, debug, }) {
|
||||
try {
|
||||
const finalDbName = database ? database : "datasquirel";
|
||||
const dbAppend = database ? `${finalDbName}.` : "";
|
||||
const dbAppend = useLocal ? "" : `${finalDbName}.`;
|
||||
const existingSocialIdUserQuery = `SELECT * FROM ${dbAppend}users WHERE social_id = ? AND social_login='1' AND social_platform = ? `;
|
||||
const existingSocialIdUserValues = [
|
||||
social_id.toString(),
|
||||
social_platform,
|
||||
];
|
||||
if (debug) {
|
||||
console.log("handleSocialDb:existingSocialIdUserQuery", existingSocialIdUserQuery);
|
||||
console.log("handleSocialDb:existingSocialIdUserValues", existingSocialIdUserValues);
|
||||
}
|
||||
let existingSocialIdUser = yield (0, varDatabaseDbHandler_1.default)({
|
||||
database: database ? database : "datasquirel",
|
||||
queryString: existingSocialIdUserQuery,
|
||||
queryValuesArray: existingSocialIdUserValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (existingSocialIdUser && existingSocialIdUser[0]) {
|
||||
if (debug) {
|
||||
console.log("handleSocialDb:existingSocialIdUser", existingSocialIdUser);
|
||||
}
|
||||
if (existingSocialIdUser === null || existingSocialIdUser === void 0 ? void 0 : existingSocialIdUser[0]) {
|
||||
return yield (0, loginSocialUser_1.default)({
|
||||
user: existingSocialIdUser[0],
|
||||
social_platform,
|
||||
@@ -48,6 +56,7 @@ function handleSocialDb(_a) {
|
||||
database,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
const finalEmail = email ? email : supEmail ? supEmail : null;
|
||||
@@ -59,11 +68,18 @@ function handleSocialDb(_a) {
|
||||
};
|
||||
}
|
||||
const existingEmailOnlyQuery = `SELECT * FROM ${dbAppend}users WHERE email='${finalEmail}'`;
|
||||
if (debug) {
|
||||
console.log("handleSocialDb:existingEmailOnlyQuery", existingEmailOnlyQuery);
|
||||
}
|
||||
let existingEmailOnly = yield (0, varDatabaseDbHandler_1.default)({
|
||||
database: database ? database : "datasquirel",
|
||||
queryString: existingEmailOnlyQuery,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (debug) {
|
||||
console.log("handleSocialDb:existingEmailOnly", existingEmailOnly);
|
||||
}
|
||||
if (existingEmailOnly && existingEmailOnly[0]) {
|
||||
return {
|
||||
success: false,
|
||||
@@ -78,6 +94,7 @@ function handleSocialDb(_a) {
|
||||
queryString: foundUserQuery,
|
||||
queryValuesArray: foundUserQueryValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (foundUser && foundUser[0]) {
|
||||
return yield (0, loginSocialUser_1.default)({
|
||||
@@ -87,6 +104,7 @@ function handleSocialDb(_a) {
|
||||
database,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
const socialHashedPassword = (0, encrypt_1.default)({
|
||||
@@ -122,6 +140,7 @@ function handleSocialDb(_a) {
|
||||
database: database ? database : "datasquirel",
|
||||
queryString: newUserQueriedQuery,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (!newUserQueried || !newUserQueried[0])
|
||||
return {
|
||||
@@ -180,6 +199,7 @@ function handleSocialDb(_a) {
|
||||
database,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -11,6 +11,7 @@ type Param = {
|
||||
database?: string;
|
||||
additionalFields?: string[];
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
/**
|
||||
* Function to login social user
|
||||
@@ -18,5 +19,5 @@ type Param = {
|
||||
* @description This function logs in the user after 'handleSocialDb' function finishes
|
||||
* the user creation or confirmation process
|
||||
*/
|
||||
export default function loginSocialUser({ user, social_platform, invitation, database, additionalFields, useLocal, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export default function loginSocialUser({ user, social_platform, invitation, database, additionalFields, useLocal, debug, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export {};
|
||||
|
||||
@@ -22,7 +22,7 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../backend/varDatabas
|
||||
* the user creation or confirmation process
|
||||
*/
|
||||
function loginSocialUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ user, social_platform, invitation, database, additionalFields, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ user, social_platform, invitation, database, additionalFields, useLocal, debug, }) {
|
||||
const finalDbName = database ? database : "datasquirel";
|
||||
const dbAppend = database ? `\`${finalDbName}\`.` : "";
|
||||
const foundUserQuery = `SELECT * FROM ${dbAppend}\`users\` WHERE email=? AND social_id=? AND social_platform=?`;
|
||||
@@ -32,6 +32,7 @@ function loginSocialUser(_a) {
|
||||
queryString: foundUserQuery,
|
||||
queryValuesArray: foundUserValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (!(foundUser === null || foundUser === void 0 ? void 0 : foundUser[0]))
|
||||
return {
|
||||
|
||||
@@ -2,4 +2,4 @@ import { APIGoogleLoginFunctionParams, APILoginFunctionReturn } from "../../../.
|
||||
/**
|
||||
* # API google login
|
||||
*/
|
||||
export default function apiGoogleLogin({ token, database, additionalFields, additionalData, }: APIGoogleLoginFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
export default function apiGoogleLogin({ token, database, additionalFields, additionalData, debug, }: APIGoogleLoginFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
|
||||
@@ -20,7 +20,7 @@ const ejson_1 = __importDefault(require("../../../../utils/ejson"));
|
||||
* # API google login
|
||||
*/
|
||||
function apiGoogleLogin(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ token, database, additionalFields, additionalData, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ token, database, additionalFields, additionalData, debug, }) {
|
||||
try {
|
||||
const gUser = yield new Promise((resolve, reject) => {
|
||||
https_1.default
|
||||
@@ -80,6 +80,7 @@ function apiGoogleLogin(_a) {
|
||||
social_platform: "google",
|
||||
social_id: sub,
|
||||
additionalFields,
|
||||
debug,
|
||||
});
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
|
||||
Vendored
+2
@@ -1073,6 +1073,7 @@ export type APIGoogleLoginFunctionParams = {
|
||||
additionalData?: {
|
||||
[key: string]: string | number;
|
||||
};
|
||||
debug?: boolean;
|
||||
};
|
||||
export type APIGoogleLoginFunction = (params: APIGoogleLoginFunctionParams) => Promise<APILoginFunctionReturn>;
|
||||
/**
|
||||
@@ -1088,6 +1089,7 @@ export type HandleSocialDbFunctionParams = {
|
||||
supEmail?: string;
|
||||
additionalFields?: string[];
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
export type HandleSocialDbFunctionReturn = {
|
||||
success: boolean;
|
||||
|
||||
Vendored
+2
-1
@@ -13,9 +13,10 @@ type Param = {
|
||||
};
|
||||
apiUserID?: string | number;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
/**
|
||||
* # SERVER FUNCTION: Login with google Function
|
||||
*/
|
||||
export default function googleAuth({ key, token, database, response, encryptionKey, encryptionSalt, additionalFields, additionalData, apiUserID, useLocal, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export default function googleAuth({ key, token, database, response, encryptionKey, encryptionSalt, additionalFields, additionalData, apiUserID, useLocal, debug, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export {};
|
||||
|
||||
Vendored
+2
-1
@@ -22,7 +22,7 @@ const write_auth_files_1 = require("../../package-shared/functions/backend/auth/
|
||||
* # SERVER FUNCTION: Login with google Function
|
||||
*/
|
||||
function googleAuth(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, token, database, response, encryptionKey, encryptionSalt, additionalFields, additionalData, apiUserID, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, token, database, response, encryptionKey, encryptionSalt, additionalFields, additionalData, apiUserID, useLocal, debug, }) {
|
||||
var _b;
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
@@ -78,6 +78,7 @@ function googleAuth(_a) {
|
||||
additionalFields,
|
||||
database: DSQL_DB_NAME,
|
||||
additionalData,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user