mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-02-23 05:39:05 +00:00
fix: guest uploads hanging
caused by auth middleware not passing the request when token is missing
This commit is contained in:
parent
4c850f4731
commit
59c5c8b7b0
@ -94,17 +94,22 @@ self.optionalUser = (req, res, next, fields) => {
|
|||||||
// Throws when token if missing only when private is set to true in config,
|
// Throws when token if missing only when private is set to true in config,
|
||||||
// thus use for routes that can handle no auth requests
|
// thus use for routes that can handle no auth requests
|
||||||
const token = req.headers.token
|
const token = req.headers.token
|
||||||
if (token) {
|
if (token === undefined) {
|
||||||
self.assertUser(token, fields, req.ip)
|
if (config.private === true) {
|
||||||
.then(user => {
|
return next(new ClientError('No token provided.', { statusCode: 403 }))
|
||||||
// Add user data to Request.locals.user
|
} else {
|
||||||
req.locals.user = user
|
// Simply bypass this middleware otherwise
|
||||||
return next()
|
return next()
|
||||||
})
|
}
|
||||||
.catch(next)
|
|
||||||
} else if (config.private === true) {
|
|
||||||
return next(new ClientError('No token provided.', { statusCode: 403 }))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.assertUser(token, fields, req.ip)
|
||||||
|
.then(user => {
|
||||||
|
// Add user data to Request.locals.user
|
||||||
|
req.locals.user = user
|
||||||
|
return next()
|
||||||
|
})
|
||||||
|
.catch(next)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.verify = async (req, res) => {
|
self.verify = async (req, res) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user