2023-04-04 21:28:46 +01:00
|
|
|
const log = require('../utils/log.utils');
|
|
|
|
const crypto = require('crypto')
|
|
|
|
const db = require('../services/dbAccess.services')
|
|
|
|
|
|
|
|
// Checks users registration key against issued keys
|
|
|
|
async function checkUser(key) {
|
|
|
|
q = {uuid: key};
|
2023-04-04 22:12:38 +01:00
|
|
|
res = db.query("registrations", q);
|
2023-04-04 21:28:46 +01:00
|
|
|
log.out(`authUtils.checkUser: DB Query answer: ${await res}`)
|
|
|
|
return await res
|
|
|
|
}
|
|
|
|
|
|
|
|
// Creates an API key for a user
|
|
|
|
async function generateKey() {
|
2023-04-04 22:12:38 +01:00
|
|
|
return crypto.randomUUID()
|
2023-04-04 21:28:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
module.export = {
|
|
|
|
checkUser,
|
|
|
|
generateKey
|
|
|
|
}
|