mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-02-22 13:19:05 +00:00
fix: less strict missing token header check
previously would still assume token is provided when the header is simply an empty string, which may be unavoidable for some clients
This commit is contained in:
parent
59c5c8b7b0
commit
6c929efa7b
@ -77,7 +77,7 @@ self.assertUser = async (token, fields, ip) => {
|
||||
self.requireUser = (req, res, next, fields) => {
|
||||
// Throws when token is missing, thus use only for users-only routes
|
||||
const token = req.headers.token
|
||||
if (token === undefined) {
|
||||
if (!token) {
|
||||
return next(new ClientError('No token provided.', { statusCode: 403 }))
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ self.optionalUser = (req, res, next, fields) => {
|
||||
// Throws when token if missing only when private is set to true in config,
|
||||
// thus use for routes that can handle no auth requests
|
||||
const token = req.headers.token
|
||||
if (token === undefined) {
|
||||
if (!token) {
|
||||
if (config.private === true) {
|
||||
return next(new ClientError('No token provided.', { statusCode: 403 }))
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user