fixed duplicate class name bug

This commit is contained in:
yamanq 2016-08-09 17:54:11 -04:00
parent 3c5b6f51a5
commit 62287f3f22

View File

@ -32,7 +32,7 @@ Meteor.methods({
input.banned = [] input.banned = []
input.blockEdit = [] input.blockEdit = []
classes.insert(input); classes.insert(input);
Meteor.call('joinClass',input.name, input.code, function(error,result){}); Meteor.call('joinClass',classes.find({input}).fetch()[0]._id, input.code, function(error,result){});
return 1; return 1;
} else { } else {
return 0; return 0;
@ -51,7 +51,7 @@ Meteor.methods({
} }
}, },
'joinClass': function(change, pass) { 'joinClass': function(change, pass) {
found = classes.find({name: change, status: true}).fetch(); found = classes.find({_id: change, status: true}).fetch();
if (Meteor.user() != null && found.length > 0 && pass === found[0].code) { if (Meteor.user() != null && found.length > 0 && pass === found[0].code) {
current = Meteor.user().profile; current = Meteor.user().profile;
current.classes.append(change); current.classes.append(change);