Skip to content

Instantly share code, notes, and snippets.

@arminyahya
Last active September 17, 2019 08:04
Show Gist options
  • Save arminyahya/d66570be97d6130bf14ff091ed25f121 to your computer and use it in GitHub Desktop.
Save arminyahya/d66570be97d6130bf14ff091ed25f121 to your computer and use it in GitHub Desktop.
var { UserList } = require('../user-list');
module.exports = (req, res, next) => {
const username = req.get('username');
const password = req.get('password');
const user = UserList.find(user => user.username === username);
if (!user) {
req.isAuth = false;
return next();
}
if (user.password !== password) {
req.isAuth = false;
return next();
}
req.isAuth = true;
next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment