Last active
September 17, 2019 08:04
-
-
Save arminyahya/d66570be97d6130bf14ff091ed25f121 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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