Update Types
This commit is contained in:
parent
7da50b1382
commit
a9007c8c83
@ -1,6 +1,7 @@
|
||||
// @ts-check
|
||||
|
||||
const decrypt = require("../../../functions/decrypt");
|
||||
// @ts-ignore
|
||||
const defaultFieldsRegexp = require("./defaultFieldsRegexp");
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,7 @@ const dbHandler = require("../../engine/utils/dbHandler");
|
||||
* "Read only" or "Full Access"? Defaults to "Read Only"
|
||||
* @param {string} params.dbFullName - Database full name
|
||||
* @param {string} params.tableName - Table name
|
||||
* @param {object} params.data - Data to add
|
||||
* @param {*} params.data - Data to add
|
||||
* @param {import("../../../types/database-schema.td").DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
||||
* @param {string} params.identifierColumnName - Update row identifier column name
|
||||
* @param {string | number} params.identifierValue - Update row identifier column value
|
||||
|
@ -117,6 +117,7 @@ async function loginLocalUser({ payload, additionalFields, dbSchema }) {
|
||||
|
||||
if (additionalFields && Array.isArray(additionalFields) && additionalFields.length > 0) {
|
||||
additionalFields.forEach((key) => {
|
||||
// @ts-ignore
|
||||
userPayload[key] = foundUser?.[0][key];
|
||||
});
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ async function localReauthUser({ existingUser, additionalFields, dbSchema }) {
|
||||
|
||||
if (additionalFields && Array.isArray(additionalFields) && additionalFields.length > 0) {
|
||||
additionalFields.forEach((key) => {
|
||||
// @ts-ignore
|
||||
userPayload[key] = foundUser?.[0][key];
|
||||
});
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ async function localGithubAuth({ res, code, email, clientId, clientSecret, addit
|
||||
|
||||
if (additionalFields && Object.keys(additionalFields).length > 0) {
|
||||
Object.keys(additionalFields).forEach((key) => {
|
||||
// @ts-ignore
|
||||
payload[key] = additionalFields[key];
|
||||
});
|
||||
}
|
||||
|
@ -122,6 +122,7 @@ async function localGoogleAuth({ dbSchema, token, clientId, response, additional
|
||||
|
||||
if (additionalFields && Object.keys(additionalFields).length > 0) {
|
||||
Object.keys(additionalFields).forEach((key) => {
|
||||
// @ts-ignore
|
||||
payloadObject[key] = additionalFields[key];
|
||||
});
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT || "";
|
||||
* image_thumbnail: string,
|
||||
* username: string,
|
||||
* },
|
||||
* res: object|null,
|
||||
* res: http.ServerResponse,
|
||||
* invitation?: object|null,
|
||||
* supEmail?: string | null,
|
||||
* additionalFields?: object,
|
||||
@ -99,7 +99,6 @@ async function handleSocialDb({ social_id, email, social_platform, payload, res,
|
||||
user: existingSocialIdUser[0],
|
||||
social_platform,
|
||||
res,
|
||||
invitation,
|
||||
database,
|
||||
additionalFields,
|
||||
});
|
||||
@ -154,7 +153,6 @@ async function handleSocialDb({ social_id, email, social_platform, payload, res,
|
||||
user: payload,
|
||||
social_platform,
|
||||
res,
|
||||
invitation,
|
||||
database,
|
||||
additionalFields,
|
||||
});
|
||||
@ -177,6 +175,7 @@ async function handleSocialDb({ social_id, email, social_platform, payload, res,
|
||||
};
|
||||
|
||||
Object.keys(payload).forEach((key) => {
|
||||
// @ts-ignore
|
||||
data[key] = payload[key];
|
||||
});
|
||||
|
||||
@ -236,7 +235,6 @@ async function handleSocialDb({ social_id, email, social_platform, payload, res,
|
||||
user: newUserQueried[0],
|
||||
social_platform,
|
||||
res,
|
||||
invitation,
|
||||
database,
|
||||
additionalFields,
|
||||
});
|
||||
@ -303,7 +301,6 @@ async function handleSocialDb({ social_id, email, social_platform, payload, res,
|
||||
* }} params.user - user object
|
||||
* @param {string} params.social_platform - Whether its "google" or "facebook" or "github"
|
||||
* @param {http.ServerResponse} params.res - Https response object
|
||||
* @param {object} params.invitation - A query object if user was invited
|
||||
* @param {string|null} params.database - Target Database
|
||||
* @param {object} [params.additionalFields] - Additional fields to be added to the user payload
|
||||
*
|
||||
@ -313,7 +310,7 @@ async function handleSocialDb({ social_id, email, social_platform, payload, res,
|
||||
* msg?: string
|
||||
* }>}
|
||||
*/
|
||||
async function loginSocialUser({ user, social_platform, res, invitation, database, additionalFields }) {
|
||||
async function loginSocialUser({ user, social_platform, res, database, additionalFields }) {
|
||||
const foundUser = await varDatabaseDbHandler({
|
||||
database: database ? database : "datasquirel",
|
||||
queryString: `SELECT * FROM users WHERE email='${user.email}' AND social_id='${user.social_id}' AND social_platform='${social_platform}'`,
|
||||
@ -350,6 +347,7 @@ async function loginSocialUser({ user, social_platform, res, invitation, databas
|
||||
|
||||
if (additionalFields && Object.keys(additionalFields).length > 0) {
|
||||
Object.keys(additionalFields).forEach((key) => {
|
||||
// @ts-ignore
|
||||
userPayload[key] = foundUser[0][key];
|
||||
});
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* Imports
|
||||
* ==============================================================================
|
||||
|
@ -47,6 +47,7 @@ async function localUpdateUser({ payload, dbSchema }) {
|
||||
|
||||
reqBodyKeys.forEach((key) => {
|
||||
if (key?.match(/^date_|^id$/)) return;
|
||||
// @ts-ignore
|
||||
finalData[key] = payload[key];
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "datasquirel",
|
||||
"version": "1.7.2",
|
||||
"version": "1.7.3",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
|
@ -43,7 +43,7 @@ const localGithubAuth = require("../../engine/user/social/github-auth");
|
||||
* @param {http.ServerResponse} params.response - HTTPS response object
|
||||
* @param {string} params.encryptionKey - Encryption key
|
||||
* @param {string} params.encryptionSalt - Encryption salt
|
||||
* @param {object} [params.additionalFields] - Additional Fields to be added to the user object
|
||||
* @param {string[]} [params.additionalFields] - Additional Fields to be added to the user object
|
||||
*
|
||||
* @returns { Promise<FunctionReturn | undefined> }
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user