Adjust middlewares
This commit is contained in:
parent
5af6122646
commit
3288ddf206
@ -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) {
|
||||||
|
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user