aboutsummaryrefslogtreecommitdiff
path: root/node_simple.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_simple.js')
-rw-r--r--node_simple.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/node_simple.js b/node_simple.js
index f2787f7..b8ada6b 100644
--- a/node_simple.js
+++ b/node_simple.js
@@ -278,7 +278,7 @@ exports.add_user = function (fields, callbackUser) {
};
// find out if this user already exists by checking their email
- exports.find_user( fields[0] ,callbackUser, function (result, callbackUser) {
+ exports.find_user( fields[0], function (result) {
if (result == false) {
// find out if the user_name is taken
@@ -363,6 +363,7 @@ exports.find_user_name = function (user_name, callback) {
*/
exports.retrieveUser = function (username, callback) {
+
mongoFactory.getConnection(uri).then(function (db) {
var users = db.collection('users');
@@ -391,7 +392,6 @@ exports.retrieveUser = function (username, callback) {
*/
exports.retrievePassword = function (username, callback) {
-
mongoFactory.getConnection(uri).then(function (db) {
var collection = db.collection('logins');
@@ -414,7 +414,7 @@ exports.retrievePassword = function (username, callback) {
/*
* This (helper) function returns true IFF email already exists in the database
* */
-exports.find_user = function (email, callbackUser, callback) {
+exports.find_user = function (email, callback) {
// make a connection
console.log("inside find_user");
mongoFactory.getConnection(uri)
@@ -424,10 +424,10 @@ exports.find_user = function (email, callbackUser, callback) {
logins.find( { email: email } ).toArray(function (err, result) {
if (err) throw err;
else if (result.length == 0) { // nothing was found so this user is new
- callback(false, callbackUser);
+ callback(false);
}
else {
- callback(true, callbackUser);
+ callback(true);
}
});
// db.close();
@@ -1058,6 +1058,7 @@ exports.sendMail = function (mail_data, callback) {
});
}
+
/*
*
* callback(success, error, data, message)
@@ -1084,6 +1085,23 @@ exports.checkMailbox = function (username, callback) {
}
+//testing
+exports.findUserByID = function (id, callback) {
+ // make a connection
+ console.log("inside findUserByID");
+ mongoFactory.getConnection(uri)
+ .then(function (db) {
+ var logins = db.collection('logins');
+ logins.find( { _id : id }, function (err, result) {
+ callback(err, result);
+ db.close();
+ });
+ })
+ .catch(function (err) {
+ console.err(err);
+ })
+};
+