-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
Background
Current behavior supports:
- string (rendered as text in response)
- object (rendered as JSON object in response)
Enhancement
Enable passing a normal middleware. This allows full customization of the response handling in the case of unauthorized:
app.use(basicAuth({
unauthorizedResponse: function(req, res, next) {
// use an application's existing error handling stack
if (req.auth) {
next(new UnauthorizedError('Login required'));
return;
}
// or send an html page
if (req.accepts('html') {
res.render('unauthorized');
return;
}
// or whatever you like!
res.status(403)
send({
message: 'That user will NEVER have access. Ever!'
});
}
}));ankur198, KClough, RedSpid3r, TheEssem, mjoyce91 and 8 more
Metadata
Metadata
Assignees
Labels
No labels