I am currently making an authentication server, but no matter what I do, I can not get this function to return something. I would like this function to return ok
if the hashed password compares to the userpassword and return invalid password
or User does not exist
if it does not.
function authenticateUser(username, password){
user = User.findOne({username});
if(!user) {
return 'User does not exist.';
}
bcrypt.compare(password, user.password, (err,success)=>{
if(err){
return 'invalid password';
}
else {
return 'ok';
}
});
}