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

View File

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

View File

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

View File

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

View File

@ -1,11 +1,4 @@
export = googleAuth; 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 * SERVER FUNCTION: Login with google Function
* ============================================================================== * ==============================================================================
@ -23,7 +16,7 @@ export = googleAuth;
* @param {string | number} [params.apiUserID] - API user ID * @param {string | number} [params.apiUserID] - API user ID
* @param {boolean} [params.useLocal] - Whether to use a remote database instead of API * @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, }: { declare function googleAuth({ key, token, database, response, encryptionKey, encryptionSalt, additionalFields, apiUserID, useLocal, }: {
key?: string; key?: string;
@ -35,9 +28,5 @@ declare function googleAuth({ key, token, database, response, encryptionKey, enc
additionalFields?: string[]; additionalFields?: string[];
apiUserID?: string | number; apiUserID?: string | number;
useLocal?: boolean; useLocal?: boolean;
}): Promise<FunctionReturn>; }): Promise<import("../../package-shared/types").APILoginFunctionReturn>;
declare namespace googleAuth {
export { FunctionReturn };
}
import http = require("http"); import http = require("http");
type FunctionReturn = object | null;

View File

@ -1,8 +1,6 @@
// @ts-check // @ts-check
const http = require("http"); const http = require("http");
const fs = require("fs");
const path = require("path");
const encrypt = require("../../package-shared/functions/dsql/encrypt"); const encrypt = require("../../package-shared/functions/dsql/encrypt");
const grabHostNames = require("../../package-shared/utils/grab-host-names"); const grabHostNames = require("../../package-shared/utils/grab-host-names");
const apiGoogleLogin = require("../../package-shared/functions/api/users/social/api-google-login"); const apiGoogleLogin = require("../../package-shared/functions/api/users/social/api-google-login");
@ -11,14 +9,6 @@ const {
writeAuthFile, writeAuthFile,
} = require("../../package-shared/functions/backend/auth/write-auth-files"); } = 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 * SERVER FUNCTION: Login with google Function
* ============================================================================== * ==============================================================================
@ -36,7 +26,7 @@ const {
* @param {string | number} [params.apiUserID] - API user ID * @param {string | number} [params.apiUserID] - API user ID
* @param {boolean} [params.useLocal] - Whether to use a remote database instead of API * @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({ async function googleAuth({
key, key,
@ -83,7 +73,7 @@ async function googleAuth({
if (!token || token?.match(/ /)) { if (!token || token?.match(/ /)) {
return { return {
success: false, success: false,
user: null, payload: null,
msg: "Please enter Google Access Token", msg: "Please enter Google Access Token",
}; };
} }
@ -91,7 +81,7 @@ async function googleAuth({
if (!database || database?.match(/ /)) { if (!database || database?.match(/ /)) {
return { return {
success: false, success: false,
user: null, payload: null,
msg: "Please provide database slug name you want to access", msg: "Please provide database slug name you want to access",
}; };
} }