Debugging req/reg functions

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-04-06 20:36:25 +01:00
parent 9cba7e7399
commit 90348f48f3
2 changed files with 13 additions and 3 deletions

View File

@ -30,7 +30,6 @@ async function increment(target) {
let update = {} let update = {}
update[target] = 1 update[target] = 1
col.updateOne({target: "counters"}, {$inc:update}) col.updateOne({target: "counters"}, {$inc:update})
return;
} }
async function addUser(uuid, domain) { // Needs testing async function addUser(uuid, domain) { // Needs testing
@ -64,10 +63,20 @@ async function userAtime(uuid) { // Needs testing
return res; 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 = { module.exports = {
query, query,
increment, increment,
addUser, addUser,
userAtime, userAtime,
addRegReq addRegReq,
delRegReq
} }

View File

@ -35,7 +35,8 @@ async function regUser(req) {
if (res.result) { if (res.result) {
let uuid = await auth.generateKey() let uuid = await auth.generateKey()
let apiKey = await db.addUser(uuid, res.domain) 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} return {status: 201, message: "User added", api_key: uuid}
} }
} }