description security and bug fixes

This commit is contained in:
Yaman Qalieh 2016-08-13 17:33:12 -04:00
parent 33c2b5e1c4
commit 41a3c1bc16
2 changed files with 8 additions and 11 deletions

View File

@ -68,7 +68,7 @@ Template.registerHelper('myClasses', () => {
} }
return array; return array;
} }
}) });
Template.main.helpers({ Template.main.helpers({
schoolName() { schoolName() {

View File

@ -160,9 +160,7 @@ Meteor.methods({
} }
}, },
'createWork': function(input) { 'createWork': function(input) {
var ref = new Date(); var ref = new Date().getTime();
var month = ref.getMonth + 1;
ref = new Date(ref.getFullYear() + "-" + month.toString() + "-" + ref.getDate()).getTime();
input.creator = Meteor.userId(); input.creator = Meteor.userId();
work.schema.validate(input); work.schema.validate(input);
var found = Meteor.findOne({ var found = Meteor.findOne({
@ -175,7 +173,7 @@ Meteor.methods({
found.banned.indexOf(Meteor.userId()) === -1 && found.banned.indexOf(Meteor.userId()) === -1 &&
found.blockEdit.indexOf(Meteor.userId()) === -1 && found.blockEdit.indexOf(Meteor.userId()) === -1 &&
input.dueDate.getTime() >= ref && worktype.indexOf(type) != -1 && input.dueDate.getTime() >= ref && worktype.indexOf(type) != -1 &&
input.name.length <= 50) { input.name.length <= 50 && input.description.length <= 150) {
input.confirmations = [Meteor.userId()]; input.confirmations = [Meteor.userId()];
input.reports = []; input.reports = [];
@ -187,9 +185,7 @@ Meteor.methods({
}, },
'editWork': function(change) { 'editWork': function(change) {
var ref = new Date(); var ref = new Date().getTime();
var month = ref.getMonth + 1;
ref = new Date(ref.getFullYear() + "-" + month.toString() + "-" + ref.getDate()).getTime();
var currentclass = classes.findOne({ var currentclass = classes.findOne({
_id: work.findOne({ _id: work.findOne({
@ -204,7 +200,7 @@ Meteor.methods({
$set: change $set: change
}); });
} else if (authorized.indexOf(Meteor.userId()) != -1) { } else if (authorized.indexOf(Meteor.userId()) != -1) {
if (change.name.length <= 50 && worktype.indexOf(type) != -1) { if (change.name.length <= 50 && change.description.length <= 150 && worktype.indexOf(type) != -1) {
Meteor.update({ Meteor.update({
_id: change._id _id: change._id
}, { }, {
@ -213,7 +209,8 @@ Meteor.methods({
dueDate: change.dueDate, dueDate: change.dueDate,
comments: change.comments, comments: change.comments,
attachments: change.attachments, attachments: change.attachments,
type: change.type type: change.type,
description: change.description
} }
}); });
} }