Skip to content

Commit

Permalink
chore: remove usage of undefined return value (#5)
Browse files Browse the repository at this point in the history
PR-URL: #5
  • Loading branch information
UlisesGascon authored Aug 1, 2024
1 parent b05baf8 commit d3b6a63
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ module.exports = function basicAuth(callback, realm) {
var authorization = req.headers.authorization;

if (req.user) return next();
if (!authorization) return unauthorized(res, realm);
if (!authorization) {
unauthorized(res, realm);
return;
}

var parts = authorization.split(' ');

Expand All @@ -81,7 +84,10 @@ module.exports = function basicAuth(callback, realm) {
// async
if (callback.length >= 3) {
callback(user, pass, function(err, user){
if (err || !user) return unauthorized(res, realm);
if (err || !user) {
unauthorized(res, realm);
return;
}
req.user = req.remoteUser = user;
next();
});
Expand Down

0 comments on commit d3b6a63

Please sign in to comment.