pis #12

Merged
fred.boniface merged 95 commits from pis into main 2023-05-06 21:54:51 +01:00
2 changed files with 4 additions and 3 deletions
Showing only changes of commit 3288ddf206 - Show all commits

View File

@ -2,11 +2,11 @@ const utils = require('../utils/auth.utils')
const log = require('../utils/log.utils') const log = require('../utils/log.utils')
module.exports = async function authCheck(req, res, next) { module.exports = async function authCheck(req, res, next) {
log.out(`authMiddlewares: Checking authentication`, "INFO") log.out(`authMiddlewares: Checking authentication`, "dbug")
try { try {
var uuid = req.headers.uuid var uuid = req.headers.uuid
} catch(err) { } catch(err) {
log.out(`authMiddlewares: No authentication attempted`, "info") log.out(`authMiddlewares: No authentication attempted`, "dbug")
err.status = 401 err.status = 401
return next(err) return next(err)
} }
@ -18,7 +18,7 @@ module.exports = async function authCheck(req, res, next) {
log.out(`authMiddlewares: Authentication attempted with incorrect key`, "warn") log.out(`authMiddlewares: Authentication attempted with incorrect key`, "warn")
return next(err) return next(err)
} else { } else {
log.out(`authMiddlewares: User authenticated`, "info") log.out(`authMiddlewares: User authenticated`, "dbug")
return next() return next()
} }
} catch(err) { } catch(err) {

View File

@ -2,6 +2,7 @@ const log = require('../utils/log.utils')
module.exports = async function requireJson(req, res, next) { module.exports = async function requireJson(req, res, next) {
if (req.headers['content-type'] !== 'application/json') { if (req.headers['content-type'] !== 'application/json') {
log.out(`requireJson.middlewares: Bad Request: Not in JSON format`)
res.status(400).send({status: 400, message: "Server requires JSON"}) res.status(400).send({status: 400, message: "Server requires JSON"})
} else { } else {
next() next()