From 942b1b191114f930cc88c19ea66592d0700ec39a Mon Sep 17 00:00:00 2001 From: yamanq Date: Sun, 7 Feb 2016 01:46:01 -0500 Subject: [PATCH] server issues, collection management, security issues --- scheduleac/.meteor/packages | 2 ++ scheduleac/.meteor/versions | 2 ++ scheduleac/client/client.html | 16 +++++++------ scheduleac/client/client.js | 42 ++++++++++++++++++++++++----------- scheduleac/server/serve.js | 25 +++++++++++++++++---- 5 files changed, 63 insertions(+), 24 deletions(-) diff --git a/scheduleac/.meteor/packages b/scheduleac/.meteor/packages index dbeddf0..6cf83d9 100644 --- a/scheduleac/.meteor/packages +++ b/scheduleac/.meteor/packages @@ -22,3 +22,5 @@ rajit:bootstrap3-datepicker twbs:bootstrap accounts-google accounts-ui +ongoworks:security +percolate:synced-cron diff --git a/scheduleac/.meteor/versions b/scheduleac/.meteor/versions index 69ede1b..94c6954 100644 --- a/scheduleac/.meteor/versions +++ b/scheduleac/.meteor/versions @@ -55,7 +55,9 @@ npm-mongo@1.4.39_1 oauth@1.1.6 oauth2@1.1.5 observe-sequence@1.0.7 +ongoworks:security@1.3.0 ordered-dict@1.0.4 +percolate:synced-cron@1.3.0 promise@0.5.1 rajit:bootstrap3-datepicker@1.5.0 random@1.0.5 diff --git a/scheduleac/client/client.html b/scheduleac/client/client.html index b7d1029..25735c3 100644 --- a/scheduleac/client/client.html +++ b/scheduleac/client/client.html @@ -11,12 +11,14 @@ diff --git a/scheduleac/client/client.js b/scheduleac/client/client.js index aade5e9..2023b9a 100644 --- a/scheduleac/client/client.js +++ b/scheduleac/client/client.js @@ -1,30 +1,46 @@ +var allowedu = {}; +allowedu["ybq987@gmail.com"] = true; +allowedu["dweinger@bloomfield.org"] = true; + +var done = false; + Meteor.subscribe('schedule'); Template.client.rendered=function() { - today = new Date() - $('#date').datepicker({ - startDate: today.toLocaleDateString(), - orientation: "top auto", - daysOfWeekDisabled: "0,6", - autoclose: true, - todayHighlight: true - }); + } - +// schedule.find({}, {sort: {timestamp: 1}, limit: 2}).fetch() Template.client.helpers({ - - status_class: function() { - return statusmap[this.status]; - } + allowed: function() { + if (!(Meteor.user() === undefined) && Meteor.user().services.google.email in allowedu) { + return true + } else { + return false; + } + } }) Template.client.events({ + "focus input": function() { + if (!done) { + today = new Date() + $('#date').datepicker({ + startDate: today.toLocaleDateString(), + orientation: "top auto", + daysOfWeekDisabled: "0,6", + autoclose: true, + todayHighlight: true + }); + done = true; + } + }, + "click button": function() { pre = document.getElementById("date").value; document.getElementById("date").value = ""; diff --git a/scheduleac/server/serve.js b/scheduleac/server/serve.js index 3885bdc..a90d266 100644 --- a/scheduleac/server/serve.js +++ b/scheduleac/server/serve.js @@ -1,15 +1,31 @@ -var currentpass = "test"; var allowed = {}; allowed["ybq987@gmail.com"] = true; allowed["dweinger@bloomfield.org"] = true; -// schedule.permit(['insert', 'update', 'remove']).never().apply(); +schedule.remove({}) +schedule.permit(['insert', 'update', 'remove']).never().apply(); + +SyncedCron.add({ + name: 'Remove Entries past today', + schedule: function(parser) { + return parser.recur().on('00:00:00').time(); + }, + job: function() { + var today = new Date(); + + // Remove matchng Documents + schedule.remove({timestamp: {$lt: today}}); + } +}); + +SyncedCron.start(); + Meteor.methods({ add_button: function(chrome, pre, post) { - if (Meteor.user().services.google.email in allowed) { + if (Meteor.user() != undefined && Meteor.user().services.google.email in allowed) { madate = pre.split("/"); date = new Date(); @@ -19,7 +35,8 @@ Meteor.methods({ schedule.insert({ "pretext": date.toDateString().slice(0,date.length), - "aftertext": post + "aftertext": post, + "timestamp": date }); } }