From ca8a0b0867031bfb58e85a66bb8845e39bfb447c Mon Sep 17 00:00:00 2001 From: Tben Date: Mon, 24 Jul 2023 22:34:01 +0100 Subject: [PATCH] minor revision --- package.json | 2 +- users/add-user.js | 27 ++++++++++++++------------- users/login-user.js | 9 ++++----- users/logout-user.js | 2 ++ 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index f0de831..e8188cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.1.83", + "version": "1.1.84", "description": "Cloud-based SQL data management tool", "main": "index.js", "scripts": { diff --git a/users/add-user.js b/users/add-user.js index c8d2b5d..c92b7a4 100644 --- a/users/add-user.js +++ b/users/add-user.js @@ -19,22 +19,23 @@ const https = require("https"); */ /** - * ============================================================================== - * Main Function + * @typedef {object} UserDataPayload + * @property {!string} first_name - First Name *Required + * @property {!string} last_name - Last Name *Required + * @property {!string} email - Email *Required + * @property {!string} password - Password *Required + * @property {string?} username - Username (Optional) + */ + +/** + * Add User to Database * ============================================================================== * @async * - * @param {{ - * key: string, - * database: string - * payload: { - * first_name: string, - * last_name: string, - * username: string, - * email: string, - * password: string, - * }, - * }} + * @param {object} props - Single object passed + * @param {string} props.key - FULL ACCESS API Key + * @param {string} props.database - Database Name + * @param {UserDataPayload} props.payload - User Data Payload * * @returns { Promise } */ diff --git a/users/login-user.js b/users/login-user.js index b77c4bc..c8a6e81 100644 --- a/users/login-user.js +++ b/users/login-user.js @@ -14,7 +14,7 @@ const encrypt = require("../functions/encrypt"); /** ****************************************************************************** */ /** - * @typedef {object} FunctionReturn + * @typedef {object} AuthenticatedUser * @property {boolean} success - Did the function run successfully? * @property {{ * id: number, @@ -37,13 +37,12 @@ const encrypt = require("../functions/encrypt"); */ /** - * ============================================================================== - * Main Function + * Login A user * ============================================================================== * @async * * @param {object} params - Single Param object containing params - * @param {String} params.key - API Key + * @param {String} params.key - FULL ACCESS API Key * @param {String} params.database - Target Database * @param {{ * email: string, @@ -53,7 +52,7 @@ const encrypt = require("../functions/encrypt"); * @param {String} params.encryptionKey - Encryption Key * @param {String} params.encryptionSalt - Encryption Salt * - * @returns { Promise} + * @returns { Promise} */ async function loginUser({ key, payload, database, response, encryptionKey, encryptionSalt }) { /** diff --git a/users/logout-user.js b/users/logout-user.js index 1a26c34..c5480e8 100644 --- a/users/logout-user.js +++ b/users/logout-user.js @@ -29,6 +29,8 @@ function logoutUser({ request, response, database }) { const authKeyName = cookiesKeys.filter((cookieKey) => cookieKey.match(keyRegexp))[0]; const csrfName = cookiesKeys.filter((cookieKey) => cookieKey.match(csrfRegexp))[0]; + console.log(authKeyName, csrfName); + if (authKeyName && csrfName) { response.setHeader("Set-Cookie", [`${authKeyName}=null;samesite=strict;path=/;HttpOnly=true;Secure=true`, `${csrfName}=null;samesite=strict;path=/;HttpOnly=true`, `dsqluid=null;samesite=strict;path=/;HttpOnly=true`]); } else {