aboutsummaryrefslogtreecommitdiff
path: root/node_simple.js
diff options
context:
space:
mode:
authornanalelfe <nargiza.nosirova@mail.utoronto.ca>2016-07-27 08:59:40 +0000
committernanalelfe <nargiza.nosirova@mail.utoronto.ca>2016-07-27 08:59:40 +0000
commitb0cbe2db0ee3311fc028e7229749726d4cfe6973 (patch)
tree76f04328c7f4026f80b20fe25a1f01a78ddf7c26 /node_simple.js
parentef5d0e0304cea09fdd67745153e617b197667479 (diff)
Added third party verification.
Diffstat (limited to 'node_simple.js')
-rw-r--r--node_simple.js86
1 files changed, 85 insertions, 1 deletions
diff --git a/node_simple.js b/node_simple.js
index e04eccf..c0595d3 100644
--- a/node_simple.js
+++ b/node_simple.js
@@ -455,7 +455,8 @@ exports.retrieve_userSolutions_count = function (username, callback) {
* IFF both the email and the user_name are not in the database already.
* If either of them exist, the user is NOT added.
*
- * @param {string[]} fields: [email, user_name, f_name, l_name, uni, department, password, phone_num]
+ * @param {string[]} fields: [email, user_name, f_name, l_name, uni, department, password, phone_num, facebookId, facebookToken,
+ * facebookName, facebookEmail]
* @param {function} callbackUser: of the form (<boolean1>, <boolean2>, <string>)
* where, <boolean1> -
* <boolean2> -
@@ -539,6 +540,89 @@ exports.add_user = function (fields, callbackUser) {
});
};
+
+
+
+/*
+ *
+ * var login_data = {
+ facebook: {
+ id: fields[8],
+ token: fields[9],
+ name: fields[10],
+ email: fields[11]
+ }
+ };
+ *
+ */
+
+
+
+
+exports.verifyExists = function(login_id, callBack) {
+ mongoFactory.getConnection(uri)
+ .then(function (db) {
+ var verif = db.collection('verifications');
+
+ verif.find( { facebookID : login_id } ).toArray(function(err, result) {
+ console.log("VERIF Y EIXSTS: ");
+ console.log(result);
+ if (err) {
+ throw err;
+ } else {
+ callBack(false, result);
+ }
+
+ });
+ });
+}
+
+
+exports.userVerifiedBefore = function(username, callback) {
+ mongoFactory.getConnection(uri)
+ .then(function (db) {
+ var verif = db.collection('verifications');
+
+ verif.find( { username : username } ).toArray(function(err, result) {
+ if (err) {
+ callback(true, null);
+ } else {
+ callback(false, result);
+ }
+
+ });
+ });
+}
+
+
+/**
+ * verification = {
+ * username: username
+ * facebook: {
+ * id: id,
+ * token: token,
+ * name: name,
+ * email: email
+ * }
+ * }
+ */
+
+exports.addVerification = function(verification, callBack) {
+ mongoFactory.getConnection(uri)
+ .then(function (db) {
+ var verif = db.collection('verifications');
+
+ verif.insertOne(verification, function (err) {
+ if (err) {
+ callBack(true);
+ } else {
+ callBack(false);
+ }
+ })
+ });
+}
+
+
/**
* This (helper) function returns true IFF user_name already exists in the database
*