pis #12
@ -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
|
||||||
}
|
}
|
@ -36,6 +36,7 @@ async function regUser(req) {
|
|||||||
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}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user