Add isAuthed to request objects

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-07-08 18:20:20 +01:00
parent 45d0e0a2c0
commit 12753d76a1

View File

@ -13,12 +13,14 @@ module.exports = async function authCheck(req, res, next) {
try {
var result = await utils.isAuthed(uuid) || false;
if (!result) {
req.isAuthed = false;
const err = new Error('Unauthorised');
err.status = 401;
log.out('authMiddlewares: Authentication attempted with incorrect key',
'warn');
return next(err);
} else {
req.isAuthed = true;
log.out('authMiddlewares: User authenticated', 'dbug');
return next();
}