diff --git a/app.js b/app.js index 6e9e08796f..0e84883155 100644 --- a/app.js +++ b/app.js @@ -213,7 +213,9 @@ app.use(function (req, res, next) { app.use(function (req, res, next) { // Remember original destination before login. var path = req.path.split('/')[1]; - if (/auth|login|logout|signup|fonts|favicon/i.test(path)) { + if (/auth|login|logout|signin|signup|fonts|favicon/i.test(path)) { + return next(); + } else if (/\/stories\/comments\/\w+/i.test(req.path)) { return next(); } req.session.returnTo = req.path; diff --git a/public/js/main.js b/public/js/main.js index 9a903a1d08..d87a768178 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -154,6 +154,10 @@ $(document).ready(function() { }); var upvoteHandler = function () { + if (typeof user == "undefined" || !user) { + window.location.href = '/signin'; + return; + } var _id = storyId; $('#upvote').unbind('click'); var alreadyUpvoted = false; diff --git a/views/stories/comments.jade b/views/stories/comments.jade index 751f65f915..546d843a28 100644 --- a/views/stories/comments.jade +++ b/views/stories/comments.jade @@ -56,7 +56,8 @@ sentinel--; if (!sentinel) { $('.comment-a-comment').on('click', 'a', function () { - if (!user) { + if (typeof user == "undefined" || !user) { + window.location.href = '/signin'; return; } $(this).unbind('click'); diff --git a/views/stories/show.jade b/views/stories/show.jade index ea5e08032e..dac2842b0b 100644 --- a/views/stories/show.jade +++ b/views/stories/show.jade @@ -56,7 +56,10 @@ $('#image-display').removeClass('hidden-element') } $('#reply-to-main-post').on('click', function() { - if (!user) return; + if (typeof user == "undefined" || !user) { + window.location.href = '/signin'; + return; + } $('#initial-comment-submit').removeClass('hidden-element'); $(this).unbind('click'); $('.comment-to-comment-formgroup').empty();