Skip to content

Instantly share code, notes, and snippets.

@czbaker
Created November 3, 2015 16:07
Show Gist options
  • Select an option

  • Save czbaker/c3fc3dcbb75cafae8c43 to your computer and use it in GitHub Desktop.

Select an option

Save czbaker/c3fc3dcbb75cafae8c43 to your computer and use it in GitHub Desktop.
Meteor.call('changeSettings', settingsDoc, function(err, result) {
if (err && err.error === "not-admin") {
console.log("Unable to update settings, not an admin!");
} else {
console.log(result);
}
});
Meteor.methods({
changeSettings: function(doc) {
console.log("Update method called.");
var currUser = Meteor.user();
if (!currUser || !Roles.userIsInRole(currUser, ['admin'])) {
throw new Meteor.Error("not-admin", "User is not logged in, or is not an admin!");
} else {
theID = Settings.findOne();
console.log("Updating settings doc with ID: " + theID);
return Settings.update(theID, { $set: { start: doc.start, end: doc.end, timeSlots: doc.timeSlots }});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment