From 90348f48f3b426ece8921132f5617113c84b32fa Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 6 Apr 2023 20:36:25 +0100 Subject: [PATCH] Debugging req/reg functions Signed-off-by: Fred Boniface --- src/services/dbAccess.services.js | 13 +++++++++++-- src/services/registration.services.js | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/services/dbAccess.services.js b/src/services/dbAccess.services.js index 8dfbe19..84399b2 100644 --- a/src/services/dbAccess.services.js +++ b/src/services/dbAccess.services.js @@ -30,7 +30,6 @@ async function increment(target) { let update = {} update[target] = 1 col.updateOne({target: "counters"}, {$inc:update}) - return; } async function addUser(uuid, domain) { // Needs testing @@ -64,10 +63,20 @@ async function userAtime(uuid) { // Needs testing return res; } +// Deletes one single registration request entry from the DB +async function delRegReq(uuid) { + log.out(`dbAccess.delRegReq: Deleting a Registration Request`) + collection = "registrations" + await client.connect() + let col = db.collection(collection) + col.deleteOne({uuid: uuid}) +} + module.exports = { query, increment, addUser, userAtime, - addRegReq + addRegReq, + delRegReq } \ No newline at end of file diff --git a/src/services/registration.services.js b/src/services/registration.services.js index f712083..2e3813f 100644 --- a/src/services/registration.services.js +++ b/src/services/registration.services.js @@ -35,7 +35,8 @@ async function regUser(req) { if (res.result) { let uuid = await auth.generateKey() let apiKey = await db.addUser(uuid, res.domain) - if (apiKey) { + if (apiKey) { + db.delRegReq(req.uuid) return {status: 201, message: "User added", api_key: uuid} } }