|
@@ -63,5 +63,30 @@ if (Meteor.isClient) {
|
|
|
Accounts.ui.config({
|
|
|
passwordSignupFields: "USERNAME_ONLY"
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
+Meteor.methods({
|
|
|
+ addTask: function (text) {
|
|
|
+ if (!Meteor.userId()) {
|
|
|
+ throw new Meteor.Error('not-authorized');
|
|
|
+ }
|
|
|
+
|
|
|
+ var task = {
|
|
|
+ text: text,
|
|
|
+ createdAt: new Date(),
|
|
|
+ owner: Meteor.userId(),
|
|
|
+ username: Meteor.user().name
|
|
|
+ };
|
|
|
+ Tasks.insert(task);
|
|
|
+ },
|
|
|
+
|
|
|
+ deleteTask: function (taskId) {
|
|
|
+
|
|
|
+
|
|
|
+ Tasks.remove(taskId);
|
|
|
+ },
|
|
|
+
|
|
|
+ setChecked: function (taskId, setChecked) {
|
|
|
+ Tasks.update(taskId, { $set : { checked: setChecked }});
|
|
|
+ }
|
|
|
+});
|