From 7d492571ff92dc5b5ac963ab156d27ef5b51f782 Mon Sep 17 00:00:00 2001 From: nanalelfe Date: Fri, 22 Jul 2016 05:05:04 -0400 Subject: Fixed login password check. Created new function retrievePassword in node_simple.js --- node_simple.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'node_simple.js') diff --git a/node_simple.js b/node_simple.js index a685cf0..f735b82 100644 --- a/node_simple.js +++ b/node_simple.js @@ -218,7 +218,26 @@ exports.retrieveUser = function (username, callback) { }); } +/* + Returns the hashed password given the username. Assume username exists. + */ + +exports.retrievePassword = function (username, callback) { + mongoFactory.getConnection(uri).then(function (db) { + + db.collection('logins').find({user_name: username}).toArray(function(err, result) { + if (err) { + // callback(success, password, message) + callback(false, null, "Error : Could not retrieve password."); + } + else { + var pwd = result[0].password; //result is an array + callback(true, pwd, "Password retrieved"); + } + }); + }); +} /* * This (helper) function returns true IFF email already exists in the database -- cgit v1.2.3