You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
281 B
13 lines
281 B
var basicAuth = require('basic-auth');
|
|
|
|
module.exports = pass => (req, res, next) => {
|
|
var cred = basicAuth(req);
|
|
|
|
if (cred && cred.pass === pass) {
|
|
req.authenticated = true;
|
|
return next();
|
|
}
|
|
|
|
res.set('WWW-Authenticate', `Basic realm="Private Area"`)
|
|
.sendStatus(401);
|
|
}
|
|
|