Remove all 'useLocal' params
This commit is contained in:
+1
-2
@@ -8,11 +8,10 @@ type Param = {
|
||||
dbFullName: string;
|
||||
tableName?: string;
|
||||
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Get Function FOr API
|
||||
*/
|
||||
export default function apiGet({ query, dbFullName, queryValues, tableName, dbSchema, useLocal, debug, }: Param): Promise<import("../../../types").GetReturn>;
|
||||
export default function apiGet({ query, dbFullName, queryValues, tableName, dbSchema, debug, }: Param): Promise<import("../../../types").GetReturn>;
|
||||
export {};
|
||||
|
||||
+3
-4
@@ -22,7 +22,7 @@ const grab_query_and_values_1 = __importDefault(require("../../../../utils/get/(
|
||||
* # Get Function FOr API
|
||||
*/
|
||||
function apiGet(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, dbFullName, queryValues, tableName, dbSchema, useLocal, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, dbFullName, queryValues, tableName, dbSchema, debug, }) {
|
||||
const queryAndValues = (0, grab_query_and_values_1.default)({
|
||||
query,
|
||||
values: queryValues,
|
||||
@@ -40,9 +40,8 @@ function apiGet(_a) {
|
||||
readOnly: true,
|
||||
dbSchema,
|
||||
tableName,
|
||||
local: useLocal,
|
||||
});
|
||||
if (debug && useLocal) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("apiGet:result", result);
|
||||
console.log("apiGet:error", error);
|
||||
}
|
||||
@@ -78,7 +77,7 @@ function apiGet(_a) {
|
||||
component: "/api/query/get/lines-85-94",
|
||||
message: error.message,
|
||||
});
|
||||
if (debug && useLocal) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("apiGet:error", error.message);
|
||||
}
|
||||
return {
|
||||
|
||||
+1
-2
@@ -5,10 +5,9 @@ type Param = {
|
||||
dbFullName: string;
|
||||
tableName?: string;
|
||||
dbSchema?: DSQL_DatabaseSchemaType;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Post Function For API
|
||||
*/
|
||||
export default function apiPost({ query, dbFullName, queryValues, tableName, dbSchema, useLocal, }: Param): Promise<PostReturn>;
|
||||
export default function apiPost({ query, dbFullName, queryValues, tableName, dbSchema, }: Param): Promise<PostReturn>;
|
||||
export {};
|
||||
|
||||
+1
-3
@@ -20,7 +20,7 @@ const runQuery_1 = __importDefault(require("../../backend/db/runQuery"));
|
||||
* # Post Function For API
|
||||
*/
|
||||
function apiPost(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, dbFullName, queryValues, tableName, dbSchema, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, dbFullName, queryValues, tableName, dbSchema, }) {
|
||||
var _b;
|
||||
if (typeof query === "string" && (query === null || query === void 0 ? void 0 : query.match(/^create |^alter |^drop /i))) {
|
||||
return { success: false, msg: "Wrong Input" };
|
||||
@@ -43,12 +43,10 @@ function apiPost(_a) {
|
||||
dbSchema: dbSchema,
|
||||
queryValuesArray: queryValues,
|
||||
tableName,
|
||||
local: useLocal,
|
||||
});
|
||||
results = result;
|
||||
if (error)
|
||||
throw error;
|
||||
/** @type {import("../../../types").DSQL_TableSchemaType | undefined} */
|
||||
let tableSchema;
|
||||
if (dbSchema) {
|
||||
const targetTable = dbSchema.tables.find((table) => table.tableName === tableName);
|
||||
|
||||
@@ -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, debug, }: HandleSocialDbFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
export default function handleSocialDb({ database, social_id, email, social_platform, payload, invitation, supEmail, additionalFields, debug, }: HandleSocialDbFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
|
||||
@@ -25,14 +25,14 @@ 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, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ database, social_id, email, social_platform, payload, invitation, supEmail, additionalFields, debug, }) {
|
||||
try {
|
||||
const finalDbName = useLocal
|
||||
const finalDbName = global.DSQL_USE_LOCAL
|
||||
? undefined
|
||||
: database
|
||||
? database
|
||||
: "datasquirel";
|
||||
const dbAppend = useLocal ? "" : `${finalDbName}.`;
|
||||
const dbAppend = global.DSQL_USE_LOCAL ? "" : `${finalDbName}.`;
|
||||
const existingSocialIdUserQuery = `SELECT * FROM ${dbAppend}users WHERE social_id = ? AND social_login='1' AND social_platform = ? `;
|
||||
const existingSocialIdUserValues = [
|
||||
social_id.toString(),
|
||||
@@ -46,7 +46,6 @@ function handleSocialDb(_a) {
|
||||
database: finalDbName,
|
||||
queryString: existingSocialIdUserQuery,
|
||||
queryValuesArray: existingSocialIdUserValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (debug) {
|
||||
@@ -59,7 +58,6 @@ function handleSocialDb(_a) {
|
||||
invitation,
|
||||
database: finalDbName,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
@@ -78,7 +76,6 @@ function handleSocialDb(_a) {
|
||||
let existingEmailOnly = yield (0, varDatabaseDbHandler_1.default)({
|
||||
database: finalDbName,
|
||||
queryString: existingEmailOnlyQuery,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (debug) {
|
||||
@@ -97,7 +94,6 @@ function handleSocialDb(_a) {
|
||||
database: finalDbName,
|
||||
queryString: foundUserQuery,
|
||||
queryValuesArray: foundUserQueryValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (foundUser && foundUser[0]) {
|
||||
@@ -107,7 +103,6 @@ function handleSocialDb(_a) {
|
||||
invitation,
|
||||
database: finalDbName,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
@@ -130,20 +125,18 @@ function handleSocialDb(_a) {
|
||||
duplicateColumnName: "email",
|
||||
duplicateColumnValue: finalEmail,
|
||||
data: Object.assign(Object.assign({}, data), { email: finalEmail }),
|
||||
useLocal,
|
||||
});
|
||||
if (newUser === null || newUser === void 0 ? void 0 : newUser.insertId) {
|
||||
if (!database) {
|
||||
/**
|
||||
* Add a Mariadb User for this User
|
||||
*/
|
||||
yield (0, addMariadbUser_1.default)({ userId: newUser.insertId, useLocal });
|
||||
yield (0, addMariadbUser_1.default)({ userId: newUser.insertId });
|
||||
}
|
||||
const newUserQueriedQuery = `SELECT * FROM ${dbAppend}users WHERE id='${newUser.insertId}'`;
|
||||
const newUserQueried = yield (0, varDatabaseDbHandler_1.default)({
|
||||
database: finalDbName,
|
||||
queryString: newUserQueriedQuery,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (!newUserQueried || !newUserQueried[0])
|
||||
@@ -202,7 +195,6 @@ function handleSocialDb(_a) {
|
||||
invitation,
|
||||
database: finalDbName,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ type Param = {
|
||||
invitation?: any;
|
||||
database?: string;
|
||||
additionalFields?: string[];
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
/**
|
||||
@@ -19,5 +18,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, debug, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export default function loginSocialUser({ user, social_platform, invitation, database, additionalFields, 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, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ user, social_platform, invitation, database, additionalFields, debug, }) {
|
||||
const finalDbName = database ? database : "datasquirel";
|
||||
const dbAppend = database ? `\`${finalDbName}\`.` : "";
|
||||
const foundUserQuery = `SELECT * FROM ${dbAppend}\`users\` WHERE email=? AND social_id=? AND social_platform=?`;
|
||||
@@ -31,7 +31,6 @@ function loginSocialUser(_a) {
|
||||
database: finalDbName,
|
||||
queryString: foundUserQuery,
|
||||
queryValuesArray: foundUserValues,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (!(foundUser === null || foundUser === void 0 ? void 0 : foundUser[0]))
|
||||
@@ -68,7 +67,6 @@ function loginSocialUser(_a) {
|
||||
(0, addAdminUserOnLogin_1.default)({
|
||||
query: invitation,
|
||||
user: userPayload,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
let result = {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { APICreateUserFunctionParams } from "../../../types";
|
||||
/**
|
||||
* # API Create User
|
||||
*/
|
||||
export default function apiCreateUser({ encryptionKey, payload, database, userId, useLocal, }: APICreateUserFunctionParams): Promise<{
|
||||
export default function apiCreateUser({ encryptionKey, payload, database, userId, }: APICreateUserFunctionParams): Promise<{
|
||||
success: boolean;
|
||||
msg: string;
|
||||
payload: null;
|
||||
|
||||
@@ -23,7 +23,7 @@ const hashPassword_1 = __importDefault(require("../../dsql/hashPassword"));
|
||||
* # API Create User
|
||||
*/
|
||||
function apiCreateUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ encryptionKey, payload, database, userId, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ encryptionKey, payload, database, userId, }) {
|
||||
const dbFullName = database;
|
||||
const API_USER_ID = userId || process.env.DSQL_API_USER_ID;
|
||||
const finalEncryptionKey = encryptionKey || process.env.DSQL_ENCRYPTION_PASSWORD;
|
||||
@@ -50,19 +50,16 @@ function apiCreateUser(_a) {
|
||||
let fields = yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: fieldsQuery,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
if (!(fields === null || fields === void 0 ? void 0 : fields[0])) {
|
||||
const newTable = yield (0, addUsersTableToDb_1.default)({
|
||||
userId: Number(API_USER_ID),
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
payload: payload,
|
||||
});
|
||||
fields = yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: fieldsQuery,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
if (!(fields === null || fields === void 0 ? void 0 : fields[0])) {
|
||||
@@ -99,7 +96,6 @@ function apiCreateUser(_a) {
|
||||
queryString: existingUserQuery,
|
||||
queryValuesArray: existingUserValues,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
if (existingUser === null || existingUser === void 0 ? void 0 : existingUser[0]) {
|
||||
return {
|
||||
@@ -116,14 +112,12 @@ function apiCreateUser(_a) {
|
||||
data: Object.assign(Object.assign({}, payload), { image: process.env.DSQL_DEFAULT_USER_IMAGE ||
|
||||
"/images/user-preset.png", image_thumbnail: process.env.DSQL_DEFAULT_USER_IMAGE ||
|
||||
"/images/user-preset-thumbnail.png" }),
|
||||
useLocal,
|
||||
});
|
||||
if (addUser === null || addUser === void 0 ? void 0 : addUser.insertId) {
|
||||
const newlyAddedUserQuery = `SELECT id,first_name,last_name,email,username,phone,image,image_thumbnail,city,state,country,zip_code,address,verification_status,more_user_data FROM ${dbFullName}.users WHERE id='${addUser.insertId}'`;
|
||||
const newlyAddedUser = yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: newlyAddedUserQuery,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
type Param = {
|
||||
dbFullName: string;
|
||||
deletedUserId: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
type Return = {
|
||||
success: boolean;
|
||||
@@ -11,5 +10,5 @@ type Return = {
|
||||
/**
|
||||
* # Update API User Function
|
||||
*/
|
||||
export default function apiDeleteUser({ dbFullName, deletedUserId, useLocal, }: Param): Promise<Return>;
|
||||
export default function apiDeleteUser({ dbFullName, deletedUserId, }: Param): Promise<Return>;
|
||||
export {};
|
||||
|
||||
@@ -19,14 +19,13 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../backend/varDatabas
|
||||
* # Update API User Function
|
||||
*/
|
||||
function apiDeleteUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbFullName, deletedUserId, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbFullName, deletedUserId, }) {
|
||||
const existingUserQuery = `SELECT * FROM ${dbFullName}.users WHERE id = ?`;
|
||||
const existingUserValues = [deletedUserId];
|
||||
const existingUser = yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: existingUserQuery,
|
||||
queryValuesArray: existingUserValues,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
if (!(existingUser === null || existingUser === void 0 ? void 0 : existingUser[0])) {
|
||||
return {
|
||||
@@ -41,7 +40,6 @@ function apiDeleteUser(_a) {
|
||||
tableName: "users",
|
||||
identifierColumnName: "id",
|
||||
identifierValue: deletedUserId,
|
||||
useLocal,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
|
||||
@@ -2,4 +2,4 @@ import { APIGetUserFunctionParams, GetUserFunctionReturn } from "../../../types"
|
||||
/**
|
||||
* # API Get User
|
||||
*/
|
||||
export default function apiGetUser({ fields, dbFullName, userId, useLocal, }: APIGetUserFunctionParams): Promise<GetUserFunctionReturn>;
|
||||
export default function apiGetUser({ fields, dbFullName, userId, }: APIGetUserFunctionParams): Promise<GetUserFunctionReturn>;
|
||||
|
||||
+1
-2
@@ -18,7 +18,7 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../backend/varDatabas
|
||||
* # API Get User
|
||||
*/
|
||||
function apiGetUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ fields, dbFullName, userId, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ fields, dbFullName, userId, }) {
|
||||
const finalDbName = dbFullName.replace(/[^a-z0-9_]/g, "");
|
||||
const query = `SELECT ${fields.join(",")} FROM ${finalDbName}.users WHERE id=?`;
|
||||
const API_USER_ID = userId || process.env.DSQL_API_USER_ID;
|
||||
@@ -26,7 +26,6 @@ function apiGetUser(_a) {
|
||||
queryString: query,
|
||||
queryValuesArray: [API_USER_ID],
|
||||
database: finalDbName,
|
||||
useLocal,
|
||||
});
|
||||
if (!foundUser || !foundUser[0]) {
|
||||
return {
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@ import { APILoginFunctionParams, APILoginFunctionReturn } from "../../../types";
|
||||
/**
|
||||
* # API Login
|
||||
*/
|
||||
export default function apiLoginUser({ encryptionKey, email, username, password, database, additionalFields, email_login, email_login_code, email_login_field, token, skipPassword, social, useLocal, dbUserId, debug, }: APILoginFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
export default function apiLoginUser({ encryptionKey, email, username, password, database, additionalFields, email_login, email_login_code, email_login_field, token, skipPassword, social, dbUserId, debug, }: APILoginFunctionParams): Promise<APILoginFunctionReturn>;
|
||||
|
||||
+1
-3
@@ -20,7 +20,7 @@ const hashPassword_1 = __importDefault(require("../../dsql/hashPassword"));
|
||||
* # API Login
|
||||
*/
|
||||
function apiLoginUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ encryptionKey, email, username, password, database, additionalFields, email_login, email_login_code, email_login_field, token, skipPassword, social, useLocal, dbUserId, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ encryptionKey, email, username, password, database, additionalFields, email_login, email_login_code, email_login_field, token, skipPassword, social, dbUserId, debug, }) {
|
||||
const dbFullName = (0, grab_db_full_name_1.default)({ dbName: database, userId: dbUserId });
|
||||
/**
|
||||
* Check input validity
|
||||
@@ -54,7 +54,6 @@ function apiLoginUser(_a) {
|
||||
queryString: `SELECT * FROM ${dbFullName}.users WHERE email = ? OR username = ?`,
|
||||
queryValuesArray: [email, username],
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (debug) {
|
||||
@@ -116,7 +115,6 @@ function apiLoginUser(_a) {
|
||||
queryString: `UPDATE ${dbFullName}.users SET ${email_login_field} = '' WHERE email = ? OR username = ?`,
|
||||
queryValuesArray: [email, username],
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
let csrfKey = Math.random().toString(36).substring(2) +
|
||||
|
||||
@@ -5,10 +5,9 @@ type Param = {
|
||||
};
|
||||
database?: string;
|
||||
additionalFields?: string[];
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Re-authenticate API user
|
||||
*/
|
||||
export default function apiReauthUser({ existingUser, database, additionalFields, useLocal, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export default function apiReauthUser({ existingUser, database, additionalFields, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export {};
|
||||
|
||||
@@ -18,13 +18,12 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../backend/varDatabas
|
||||
* # Re-authenticate API user
|
||||
*/
|
||||
function apiReauthUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ existingUser, database, additionalFields, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ existingUser, database, additionalFields, }) {
|
||||
let foundUser = (existingUser === null || existingUser === void 0 ? void 0 : existingUser.id) && existingUser.id.toString().match(/./)
|
||||
? yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: `SELECT * FROM ${database}.users WHERE id=?`,
|
||||
queryValuesArray: [existingUser.id.toString()],
|
||||
database,
|
||||
useLocal,
|
||||
})
|
||||
: null;
|
||||
if (!foundUser || !foundUser[0])
|
||||
|
||||
@@ -10,7 +10,6 @@ type Param = {
|
||||
mail_username?: string;
|
||||
mail_password?: string;
|
||||
html: string;
|
||||
useLocal?: boolean;
|
||||
response?: http.ServerResponse & {
|
||||
[s: string]: any;
|
||||
};
|
||||
@@ -19,5 +18,5 @@ type Param = {
|
||||
/**
|
||||
* # Send Email Login Code
|
||||
*/
|
||||
export default function apiSendEmailCode({ email, database, email_login_field, mail_domain, mail_port, sender, mail_username, mail_password, html, useLocal, response, extraCookies, }: Param): Promise<SendOneTimeCodeEmailResponse>;
|
||||
export default function apiSendEmailCode({ email, database, email_login_field, mail_domain, mail_port, sender, mail_username, mail_password, html, response, extraCookies, }: Param): Promise<SendOneTimeCodeEmailResponse>;
|
||||
export {};
|
||||
|
||||
@@ -22,7 +22,7 @@ const serialize_cookies_1 = __importDefault(require("../../../utils/serialize-co
|
||||
* # Send Email Login Code
|
||||
*/
|
||||
function apiSendEmailCode(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ email, database, email_login_field, mail_domain, mail_port, sender, mail_username, mail_password, html, useLocal, response, extraCookies, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ email, database, email_login_field, mail_domain, mail_port, sender, mail_username, mail_password, html, response, extraCookies, }) {
|
||||
if (email === null || email === void 0 ? void 0 : email.match(/ /)) {
|
||||
return {
|
||||
success: false,
|
||||
@@ -36,7 +36,6 @@ function apiSendEmailCode(_a) {
|
||||
queryString: foundUserQuery,
|
||||
queryValuesArray: foundUserValues,
|
||||
database,
|
||||
useLocal,
|
||||
});
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
@@ -85,7 +84,6 @@ function apiSendEmailCode(_a) {
|
||||
queryString: setTempCodeQuery,
|
||||
queryValuesArray: setTempCodeValues,
|
||||
database,
|
||||
useLocal,
|
||||
});
|
||||
/** @type {import("../../../types").SendOneTimeCodeEmailResponse} */
|
||||
const resObject = {
|
||||
|
||||
@@ -4,7 +4,6 @@ type Param = {
|
||||
};
|
||||
dbFullName: string;
|
||||
updatedUserId: string | number;
|
||||
useLocal?: boolean;
|
||||
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
|
||||
};
|
||||
type Return = {
|
||||
@@ -15,5 +14,5 @@ type Return = {
|
||||
/**
|
||||
* # Update API User Function
|
||||
*/
|
||||
export default function apiUpdateUser({ payload, dbFullName, updatedUserId, useLocal, dbSchema, }: Param): Promise<Return>;
|
||||
export default function apiUpdateUser({ payload, dbFullName, updatedUserId, dbSchema, }: Param): Promise<Return>;
|
||||
export {};
|
||||
|
||||
@@ -22,14 +22,13 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../backend/varDatabas
|
||||
* # Update API User Function
|
||||
*/
|
||||
function apiUpdateUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ payload, dbFullName, updatedUserId, useLocal, dbSchema, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ payload, dbFullName, updatedUserId, dbSchema, }) {
|
||||
const existingUserQuery = `SELECT * FROM ${dbFullName}.users WHERE id = ?`;
|
||||
const existingUserValues = [updatedUserId];
|
||||
const existingUser = yield (0, varDatabaseDbHandler_1.default)({
|
||||
queryString: existingUserQuery,
|
||||
queryValuesArray: existingUserValues,
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
});
|
||||
if (!(existingUser === null || existingUser === void 0 ? void 0 : existingUser[0])) {
|
||||
return {
|
||||
@@ -75,7 +74,6 @@ function apiUpdateUser(_a) {
|
||||
identifierColumnName: "id",
|
||||
identifierValue: updatedUserId,
|
||||
data: data,
|
||||
useLocal,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
|
||||
+1
-2
@@ -9,7 +9,6 @@ type Param = {
|
||||
email: string;
|
||||
encryptionKey?: string;
|
||||
encryptionSalt?: string;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
apiUserID?: string | number;
|
||||
dbUserId?: string | number;
|
||||
@@ -17,7 +16,7 @@ type Param = {
|
||||
/**
|
||||
* # API Login
|
||||
*/
|
||||
export default function apiSendResetPasswordLink({ database, email, apiUserID, dbUserId, debug, encryptionKey, encryptionSalt, key, useLocal, }: Param): Promise<Return>;
|
||||
export default function apiSendResetPasswordLink({ database, email, dbUserId, debug, }: Param): Promise<Return>;
|
||||
export type SendResetPasswordParam = Param;
|
||||
export type SendResetPasswordReturn = Return;
|
||||
export {};
|
||||
|
||||
+1
-2
@@ -19,7 +19,7 @@ const varDatabaseDbHandler_1 = __importDefault(require("../../../backend/varData
|
||||
* # API Login
|
||||
*/
|
||||
function apiSendResetPasswordLink(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ database, email, apiUserID, dbUserId, debug, encryptionKey, encryptionSalt, key, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ database, email, dbUserId, debug, }) {
|
||||
const dbFullName = (0, grab_db_full_name_1.default)({ dbName: database, userId: dbUserId });
|
||||
/**
|
||||
* Check input validity
|
||||
@@ -36,7 +36,6 @@ function apiSendResetPasswordLink(_a) {
|
||||
queryString: `SELECT * FROM ${dbFullName}.users WHERE email = ? OR username = ?`,
|
||||
queryValuesArray: [email, email],
|
||||
database: dbFullName,
|
||||
useLocal,
|
||||
debug,
|
||||
});
|
||||
if (debug) {
|
||||
|
||||
@@ -9,10 +9,9 @@ type Param = {
|
||||
[s: string]: string | number;
|
||||
};
|
||||
email?: string;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # API Login with Github
|
||||
*/
|
||||
export default function apiGithubLogin({ code, clientId, clientSecret, database, additionalFields, email, additionalData, useLocal, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export default function apiGithubLogin({ code, clientId, clientSecret, database, additionalFields, email, additionalData, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export {};
|
||||
|
||||
@@ -20,7 +20,7 @@ const camelJoinedtoCamelSpace_1 = __importDefault(require("../../../../utils/cam
|
||||
* # API Login with Github
|
||||
*/
|
||||
function apiGithubLogin(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ code, clientId, clientSecret, database, additionalFields, email, additionalData, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ code, clientId, clientSecret, database, additionalFields, email, additionalData, }) {
|
||||
if (!code || !clientId || !clientSecret || !database) {
|
||||
return {
|
||||
success: false,
|
||||
@@ -80,7 +80,6 @@ function apiGithubLogin(_a) {
|
||||
social_id: socialId,
|
||||
supEmail: email,
|
||||
additionalFields,
|
||||
useLocal,
|
||||
});
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
|
||||
@@ -2,4 +2,4 @@ import { APIGoogleLoginFunctionParams, APILoginFunctionReturn } from "../../../.
|
||||
/**
|
||||
* # API google login
|
||||
*/
|
||||
export default function apiGoogleLogin({ token, database, additionalFields, additionalData, debug, useLocal, }: 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, debug, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ token, database, additionalFields, additionalData, debug, }) {
|
||||
try {
|
||||
const gUser = yield new Promise((resolve, reject) => {
|
||||
https_1.default
|
||||
@@ -71,7 +71,6 @@ function apiGoogleLogin(_a) {
|
||||
social_id: sub,
|
||||
additionalFields,
|
||||
debug,
|
||||
useLocal,
|
||||
});
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user