Created
March 28, 2016 09:09
-
-
Save dai-shi/519b49f2da5d282bbb52 to your computer and use it in GitHub Desktop.
This file contains 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
diff --git a/imports/api/tasks.js b/imports/api/tasks.js | |
index 441feee..9d5b56a 100644 | |
--- a/imports/api/tasks.js | |
+++ b/imports/api/tasks.js | |
@@ -36,12 +36,24 @@ Meteor.methods({ | |
'tasks.remove'(taskId) { | |
check(taskId, String); | |
+ const task = Tasks.findOne(taskId); | |
+ if (task.private && task.owner !== Meteor.userId()) { | |
+ // If the task is private, make sure only the owner can delete it | |
+ throw new Meteor.Error('not-authorized'); | |
+ } | |
+ | |
Tasks.remove(taskId); | |
}, | |
'tasks.setChecked'(taskId, setChecked) { | |
check(taskId, String); | |
check(setChecked, Boolean); | |
+ const task = Tasks.findOne(taskId); | |
+ if (task.private && task.owner !== Meteor.userId()) { | |
+ // If the task is private, make sure only the owner can check it off | |
+ throw new Meteor.Error('not-authorized'); | |
+ } | |
+ | |
Tasks.update(taskId, { $set: { checked: setChecked } }); | |
}, | |
'tasks.setPrivate'(taskId, setToPrivate) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment