fix leaveClass function

This commit is contained in:
yamanq 2016-08-09 18:23:02 -04:00
parent ccde0fcc11
commit 470b0cf41e

View File

@ -66,9 +66,13 @@ Meteor.methods({
profile = Meteor.user().profile profile = Meteor.user().profile
index = profile.classes.indexOf(change) index = profile.classes.indexOf(change)
if (index >= 0) { if (index >= 0) {
if (classes.find({_id: change}).fetch()[0].admin != Meteor.userId()) {
profile.classes.splice(index, 1); profile.classes.splice(index, 1);
Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}}); Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}});
return 1 return 1
} else {
throw "You are the admin of this class. Transfer ownership in order to leave this class."
}
} }
} }