This commit is contained in:
Benjamin Toby
2025-07-07 09:14:37 +01:00
parent 6acf0f2cd6
commit ccb5605b58
30 changed files with 292 additions and 166 deletions
@@ -20,6 +20,10 @@ type Param = {
debug?: boolean;
secureCookie?: boolean;
loginOnly?: boolean;
/**
* Login without calling external API
*/
forceLocal?: boolean;
};
/**
@@ -38,6 +42,7 @@ export default async function googleAuth({
debug,
secureCookie,
loginOnly,
forceLocal,
}: Param): Promise<APILoginFunctionReturn> {
const grabedHostNames = grabHostNames({
userId: apiUserID || process.env.DSQL_API_USER_ID,
@@ -89,21 +94,7 @@ export default async function googleAuth({
success: false,
};
/**
* Check for local DB settings
*
* @description Look for local db settings in `.env` file and by pass the http request if available
*/
const { DSQL_DB_HOST, DSQL_DB_USERNAME, DSQL_DB_PASSWORD, DSQL_DB_NAME } =
process.env;
if (
DSQL_DB_HOST?.match(/./) &&
DSQL_DB_USERNAME?.match(/./) &&
DSQL_DB_PASSWORD?.match(/./) &&
DSQL_DB_NAME?.match(/./) &&
global.DSQL_USE_LOCAL
) {
if (forceLocal) {
if (debug) {
console.log(`Google login with Local Paradigm ...`);
}
@@ -113,6 +104,7 @@ export default async function googleAuth({
additionalFields,
additionalData,
debug,
loginOnly,
});
} else {
httpResponse = await new Promise((resolve, reject) => {