When env=development use middleware to always auth.

This commit is contained in:
2021-02-19 00:39:59 +01:00
parent 7bd2e9d931
commit 48c1842b8b
3 changed files with 16 additions and 6 deletions

View File

@@ -0,0 +1,6 @@
const alwaysAuthenticatedWhenLocalhost = (req, res, next) => {
req.isAuthenticated = () => true;
return next();
};
module.exports = alwaysAuthenticatedWhenLocalhost;

View File

@@ -1,10 +1,4 @@
const mustBeAuthenticated = (req, res, next) => {
if (process.env.NODE_ENV == "development") {
console.info(`Restricted endpoint ${req.originalUrl}, allowing with environment development.`)
req.isAuthenticated = () => true;
return next();
}
if (!req.isAuthenticated()) {
return res.status(401).send({
success: false,