Major refactoring: Add user id to API routes

This commit is contained in:
Benjamin Toby
2024-11-27 11:02:03 +01:00
parent a529d0bd08
commit b047d6557c
21 changed files with 144 additions and 49 deletions
+7 -2
View File
@@ -45,6 +45,7 @@ const grabHostNames = require("../../package-shared/utils/grab-host-names");
* @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 {boolean} [params.user_id] - User ID
*
* @returns { Promise<FunctionReturn | undefined> }
*/
@@ -59,13 +60,15 @@ async function githubAuth({
encryptionKey,
encryptionSalt,
additionalFields,
user_id,
}) {
/**
* Check inputs
*
* @description Check inputs
*/
const { host, port, scheme } = grabHostNames();
const grabedHostNames = grabHostNames();
const { host, port, scheme } = grabedHostNames;
if (!key || key?.match(/ /)) {
return {
@@ -205,7 +208,9 @@ async function githubAuth({
},
port,
hostname: host,
path: `/api/user/github-login`,
path: `/api/user/${
user_id || grabedHostNames.user_id
}/github-login`,
},
/**
+7 -2
View File
@@ -43,6 +43,7 @@ const grabHostNames = require("../../package-shared/utils/grab-host-names");
* @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 {boolean} [params.user_id] - User ID
*
* @returns { Promise<FunctionReturn> }
*/
@@ -55,8 +56,10 @@ async function googleAuth({
encryptionKey,
encryptionSalt,
additionalFields,
user_id,
}) {
const { host, port, scheme } = grabHostNames();
const grabedHostNames = grabHostNames();
const { host, port, scheme } = grabedHostNames;
/**
* Check inputs
@@ -201,7 +204,9 @@ async function googleAuth({
},
port,
hostname: host,
path: `/api/user/google-login`,
path: `/api/user/${
user_id || grabedHostNames.user_id
}/google-login`,
},
/**