Response adjustments

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-08-30 21:34:06 +01:00
parent 0aa42c4743
commit 45183f619e
4 changed files with 7 additions and 4 deletions

View File

@ -52,7 +52,7 @@ async function getStation(req, res, next) {
if (!req.isAuthed) {
const err = new Error("Unauthorized");
err.status = 401;
throw err;
return next(err);
}
res.json(await ldb.get(id, true));
} else {

View File

@ -6,7 +6,7 @@ module.exports = async function authCheck(req, res, next) {
try {
var uuid = req.headers.uuid;
} catch (err) {
log.out("authMiddlewares: User !isAuthed", "dbug");
log.out("authMiddlewares: UNABLE TO READ HEADER 'UUID' - User !isAuthed", "warn");
req.isAuthed = false;
return next();
}
@ -21,6 +21,7 @@ module.exports = async function authCheck(req, res, next) {
}
return next();
} catch (err) {
log.out("authMiddlewares: Unable to check auth, default to !isAuthed", "warn")
req.isAuthed = false;
return next();
}

View File

@ -23,6 +23,8 @@ async function query(collection, query, returnId = false) {
}
log.out(`dbAccess.query: Running Query: ${JSON.stringify(query)}`, "info");
increment(collection);
log.out('dbAccess.query: Query response:')
console.log(await qcursor.toArray())
return await qcursor.toArray();
}

View File

@ -6,9 +6,9 @@ const fs = require("fs/promises");
import { minifyMail } from "./minify.utils";
// Checks users registration key against issued keys
async function isAuthed(uuid: string) {
async function isAuthed(uuid: string): Promise<boolean> {
// Needs testing
const q = { uuid: uuid };
const q = { /*uuid: uuid*/ };
const res = await db.query("users", q);
logs.out(
"authUtils.checkUser: DB Query answer: " + JSON.stringify(res[0]),