diff options
| author | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-22 09:05:04 +0000 |
|---|---|---|
| committer | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-22 09:06:06 +0000 |
| commit | 7d492571ff92dc5b5ac963ab156d27ef5b51f782 (patch) | |
| tree | 8b794607d5b218dfd574a1cedfaf5597136c06c5 /node_simple.js | |
| parent | 794c7c94d35d096bbb62a569da73ddeeb4a49c52 (diff) | |
Fixed login password check. Created new function retrievePassword in node_simple.js
Diffstat (limited to 'node_simple.js')
| -rw-r--r-- | node_simple.js | 19 |
1 files changed, 19 insertions, 0 deletions
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 |
