From 790a4f941d3239c47f1282c540125c40536bf8e9 Mon Sep 17 00:00:00 2001 From: MrRenter Date: Sat, 18 Apr 2015 02:46:16 -0400 Subject: [PATCH] Removed alert and added server side check for 10minutes --- controllers/story.js | 21 +++++++++++++-------- views/stories/comments.jade | 1 - 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/controllers/story.js b/controllers/story.js index 4ab8351393..24b11ddba9 100755 --- a/controllers/story.js +++ b/controllers/story.js @@ -445,15 +445,20 @@ exports.commentEdit = function(req, res, next){ return next(err); } cmt = cmt.pop(); - cmt.body = sanitizedBody; - cmt.commentOn = Date.now(); - cmt.save(function (err) { - if (err) { - return next(err); - } - res.send(true); + var rightNow = Date.now(); + if ((rightNow - cmt.commentOn) < 600000){ + cmt.body = sanitizedBody; + cmt.commentOn = Date.now(); + cmt.save(function (err) { + if (err) { + return next(err); + } + res.send(true); + }); + } + req.flash('errors', { + msg: 'Comment is too old to edit' }); - //commentSave(comment, Comment, res, next); }); }; diff --git a/views/stories/comments.jade b/views/stories/comments.jade index 43d1701288..15d0b2deaf 100755 --- a/views/stories/comments.jade +++ b/views/stories/comments.jade @@ -62,7 +62,6 @@ sentinel--; if (!sentinel) { $('.comment-a-comment').on('click', 'a', function() { - alert($(this).hasClass("edit-btn")); var editOrComment = 'comment'; if ($(this).hasClass("edit-btn")){ editOrComment = 'edit';