newStaffLDB-API #48
@ -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 {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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]),
|
||||
|
Loading…
Reference in New Issue
Block a user