This commit is contained in:
Benjamin Toby 2024-12-10 19:51:02 +01:00
parent ef6a7f1411
commit ff9ce28d1f
6 changed files with 10 additions and 38 deletions

View File

@ -45,7 +45,7 @@ module.exports = async function apiGoogleLogin({
if (!database || typeof database != "string" || database?.match(/ /)) {
return {
success: false,
user: undefined,
payload: undefined,
msg: "Please provide a database slug(database name in lowercase with no spaces)",
};
}
@ -89,7 +89,7 @@ module.exports = async function apiGoogleLogin({
return {
success: false,
user: undefined,
payload: undefined,
msg: error.message,
};
}

View File

@ -1057,10 +1057,7 @@ export type APIGoogleLoginFunctionParams = {
database: string;
additionalFields?: string[];
};
export type APIGoogleLoginFunctionReturn = {
dsqlUserId?: number | string;
} & HandleSocialDbFunctionReturn;
export type APIGoogleLoginFunction = (params: APIGoogleLoginFunctionParams) => Promise<APIGoogleLoginFunctionReturn>;
export type APIGoogleLoginFunction = (params: APIGoogleLoginFunctionParams) => Promise<APILoginFunctionReturn>;
/**
* Handle Social DB Function
*/

View File

@ -1269,13 +1269,9 @@ export type APIGoogleLoginFunctionParams = {
additionalFields?: string[];
};
export type APIGoogleLoginFunctionReturn = {
dsqlUserId?: number | string;
} & HandleSocialDbFunctionReturn;
export type APIGoogleLoginFunction = (
params: APIGoogleLoginFunctionParams
) => Promise<APIGoogleLoginFunctionReturn>;
) => Promise<APILoginFunctionReturn>;
/**
* Handle Social DB Function

View File

@ -1,6 +1,6 @@
{
"name": "@moduletrace/datasquirel",
"version": "2.9.2",
"version": "2.9.3",
"description": "Cloud-based SQL data management tool",
"main": "index.js",
"bin": {

View File

@ -1,11 +1,4 @@
export = googleAuth;
/**
* @typedef {object | null} FunctionReturn
* @property {boolean} success - Did the function run successfully?
* @property {import("../../types/user.td").DATASQUIREL_LoggedInUser | null} user - Returned User
* @property {number} [dsqlUserId] - Dsql User Id
* @property {string} [msg] - Response message
*/
/**
* SERVER FUNCTION: Login with google Function
* ==============================================================================
@ -23,7 +16,7 @@ export = googleAuth;
* @param {string | number} [params.apiUserID] - API user ID
* @param {boolean} [params.useLocal] - Whether to use a remote database instead of API
*
* @returns { Promise<FunctionReturn> }
* @returns { Promise<import("../../package-shared/types").APILoginFunctionReturn> }
*/
declare function googleAuth({ key, token, database, response, encryptionKey, encryptionSalt, additionalFields, apiUserID, useLocal, }: {
key?: string;
@ -35,9 +28,5 @@ declare function googleAuth({ key, token, database, response, encryptionKey, enc
additionalFields?: string[];
apiUserID?: string | number;
useLocal?: boolean;
}): Promise<FunctionReturn>;
declare namespace googleAuth {
export { FunctionReturn };
}
}): Promise<import("../../package-shared/types").APILoginFunctionReturn>;
import http = require("http");
type FunctionReturn = object | null;

View File

@ -1,8 +1,6 @@
// @ts-check
const http = require("http");
const fs = require("fs");
const path = require("path");
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");
@ -11,14 +9,6 @@ const {
writeAuthFile,
} = require("../../package-shared/functions/backend/auth/write-auth-files");
/**
* @typedef {object | null} FunctionReturn
* @property {boolean} success - Did the function run successfully?
* @property {import("../../types/user.td").DATASQUIREL_LoggedInUser | null} user - Returned User
* @property {number} [dsqlUserId] - Dsql User Id
* @property {string} [msg] - Response message
*/
/**
* SERVER FUNCTION: Login with google Function
* ==============================================================================
@ -36,7 +26,7 @@ const {
* @param {string | number} [params.apiUserID] - API user ID
* @param {boolean} [params.useLocal] - Whether to use a remote database instead of API
*
* @returns { Promise<FunctionReturn> }
* @returns { Promise<import("../../package-shared/types").APILoginFunctionReturn> }
*/
async function googleAuth({
key,
@ -83,7 +73,7 @@ async function googleAuth({
if (!token || token?.match(/ /)) {
return {
success: false,
user: null,
payload: null,
msg: "Please enter Google Access Token",
};
}
@ -91,7 +81,7 @@ async function googleAuth({
if (!database || database?.match(/ /)) {
return {
success: false,
user: null,
payload: null,
msg: "Please provide database slug name you want to access",
};
}