Created
November 3, 2015 16:07
-
-
Save czbaker/c3fc3dcbb75cafae8c43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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