MCPcopy Create free account
hub / github.com/LionC/express-basic-auth / unauthorized

Function unauthorized

index.js:66–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64 return next()
65
66 function unauthorized() {
67 if(challenge) {
68 var challengeString = 'Basic'
69 var realmName = realm(req)
70
71 if(realmName)
72 challengeString += ' realm="' + realmName + '"'
73
74 res.set('WWW-Authenticate', challengeString)
75 }
76
77 //TODO: Allow response body to be JSON (maybe autodetect?)
78 const response = getResponseBody(req)
79
80 if(typeof response == 'string')
81 return res.status(401).send(response)
82
83 return res.status(401).json(response)
84 }
85
86 function authorizerCallback(err, approved) {
87 assert.ifError(err)

Callers 2

buildMiddlewareFunction · 0.85
authorizerCallbackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…