From 4c416cdd1857562a33bb77b0948ca6f2f8fbc6aa Mon Sep 17 00:00:00 2001 From: yamanq Date: Mon, 8 Aug 2016 20:46:49 -0400 Subject: [PATCH] added joinClass function --- hourglass/server/main.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hourglass/server/main.js b/hourglass/server/main.js index b9d6cf5..aa6a5a7 100644 --- a/hourglass/server/main.js +++ b/hourglass/server/main.js @@ -22,7 +22,18 @@ _uuid4 = function(cc) { current.grade = change[1]; if (schools.find({name:current.school}).fetch().length > 0 && Number.isInteger(current.grade) && current.grade >= 9 && current.grade <= 12) { - Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}}) + Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}}); + return 1; + } else { + return 0; + } + }, + 'joinClass': function(change, pass) { + found = classes.find({name: change}).fetch(); + if (Meteor.user() != null && found.length > 0 && pass === found[0].code) { + current = Meteor.user().profile; + current.classes.append(change); + Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}}); return 1; } else { return 0;