add logging for auth errors

This commit is contained in:
2023-05-02 12:58:12 +02:00
parent 9397e2b2be
commit a8618f229b
+8 -2
View File
@@ -17,9 +17,15 @@ router.post(
validateErrors,
async (req, res, next) => {
if (!req) return res.sendStatus(500)
if (!req.headers.authorization) return res.sendStatus(403)
if (!req.headers.authorization) {
console.error("no authorization header")
return res.sendStatus(403)
}
const query = await CheckServerToken(req.headers.authorization.split(' ')[1])
if (!query || !query.id) return res.sendStatus(403)
if (!query || !query.id) {
console.error("incorrect token : " + req.headers.authorization.split(' ')[1])
return res.sendStatus(403)
}
next()
}
)