Merge pull request #473 from terakilobyte/staging
E-mail signin from camper news
This commit is contained in:
@ -9,7 +9,7 @@ var async = require('async'),
|
|||||||
_ = require('lodash'),
|
_ = require('lodash'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
|
|
||||||
constantStrings = require('constantStrings.json'),
|
constantStrings = require('./constantStrings.json'),
|
||||||
User = require('../models/User'),
|
User = require('../models/User'),
|
||||||
Challenge = require('./../models/Challenge'),
|
Challenge = require('./../models/Challenge'),
|
||||||
Story = require('./../models/Story'),
|
Story = require('./../models/Story'),
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
var moment = require('moment'),
|
/* eslint-disable no-catch-shadow, no-unused-vars */
|
||||||
mongodb = require('mongodb'),
|
var R = require('ramda'),
|
||||||
nodemailer = require('nodemailer'),
|
debug = require('debug')('freecc:cntr:story'),
|
||||||
sanitizeHtml = require('sanitize-html'),
|
|
||||||
MongoClient = mongodb.MongoClient,
|
|
||||||
resources = require('./resources'),
|
|
||||||
secrets = require('../config/secrets'),
|
|
||||||
Story = require('./../models/Story'),
|
Story = require('./../models/Story'),
|
||||||
Comment = require('./../models/Comment'),
|
Comment = require('./../models/Comment'),
|
||||||
User = require('./../models/User');
|
User = require('./../models/User'),
|
||||||
|
moment = require('moment'),
|
||||||
|
resources = require('./resources'),
|
||||||
|
mongodb = require('mongodb'),
|
||||||
|
MongoClient = mongodb.MongoClient,
|
||||||
|
secrets = require('../config/secrets'),
|
||||||
|
nodemailer = require('nodemailer'),
|
||||||
|
sanitizeHtml = require('sanitize-html');
|
||||||
|
|
||||||
function hotRank(timeValue, rank) {
|
function hotRank(timeValue, rank) {
|
||||||
/*
|
/*
|
||||||
@ -227,14 +230,13 @@ exports.upvote = function(req, res, next) {
|
|||||||
);
|
);
|
||||||
story.markModified('rank');
|
story.markModified('rank');
|
||||||
story.save();
|
story.save();
|
||||||
User.find({ '_id': story.author.userId }, function(err, user) {
|
User.findOne({'_id': story.author.userId}, function(err, user) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
user = user.pop();
|
|
||||||
user.progressTimestamps.push(Date.now() || 0);
|
user.progressTimestamps.push(Date.now() || 0);
|
||||||
user.save(function (err) {
|
user.save(function (err, user) {
|
||||||
req.user.save(function (err) {
|
req.user.save(function (err, user) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
@ -336,9 +338,7 @@ exports.storySubmission = function(req, res, next) {
|
|||||||
if (link.search(/^https?:\/\//g) === -1) {
|
if (link.search(/^https?:\/\//g) === -1) {
|
||||||
link = 'http://' + link;
|
link = 'http://' + link;
|
||||||
}
|
}
|
||||||
Story.count(
|
Story.count({ storyLink: new RegExp('^' + storyLink + '(?: [0-9]+)?$', 'i')}, function (err, storyCount) {
|
||||||
{ storyLink: new RegExp('^' + storyLink + '(?: [0-9]+)?$', 'i') },
|
|
||||||
function (err, storyCount) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return res.status(500);
|
return res.status(500);
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ exports.storySubmission = function(req, res, next) {
|
|||||||
return res.status(500);
|
return res.status(500);
|
||||||
}
|
}
|
||||||
req.user.progressTimestamps.push(Date.now() || 0);
|
req.user.progressTimestamps.push(Date.now() || 0);
|
||||||
req.user.save(function (err) {
|
req.user.save(function (err, user) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
@ -392,8 +392,7 @@ exports.storySubmission = function(req, res, next) {
|
|||||||
storyLink: story.storyLink.replace(/\s/g, '-').toLowerCase()
|
storyLink: story.storyLink.replace(/\s/g, '-').toLowerCase()
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.commentSubmit = function(req, res, next) {
|
exports.commentSubmit = function(req, res, next) {
|
||||||
@ -515,9 +514,7 @@ exports.storySubmission = function(req, res, next) {
|
|||||||
try {
|
try {
|
||||||
// Based on the context retrieve the parent
|
// Based on the context retrieve the parent
|
||||||
// object of the comment (Story/Comment)
|
// object of the comment (Story/Comment)
|
||||||
Context.find(
|
Context.find({'_id': data.associatedPost}, function (err, associatedContext) {
|
||||||
{ '_id': data.associatedPost },
|
|
||||||
function (err, associatedContext) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
@ -532,9 +529,7 @@ exports.storySubmission = function(req, res, next) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Find the author of the parent object
|
// Find the author of the parent object
|
||||||
User.findOne(
|
User.findOne({'profile.username': associatedContext.author.username}, function(err, recipient) {
|
||||||
{ 'profile.username': associatedContext.author.username },
|
|
||||||
function(err, recipient) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
@ -578,11 +573,10 @@ exports.storySubmission = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// delete comment
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -53,6 +53,9 @@ exports.postSignin = function(req, res, next) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
req.flash('success', { msg: 'Success! You are logged in.' });
|
req.flash('success', { msg: 'Success! You are logged in.' });
|
||||||
|
if (/hotStories/.test(req.session.returnTo)) {
|
||||||
|
return res.redirect('../news');
|
||||||
|
}
|
||||||
return res.redirect(req.session.returnTo || '/');
|
return res.redirect(req.session.returnTo || '/');
|
||||||
});
|
});
|
||||||
})(req, res, next);
|
})(req, res, next);
|
||||||
|
Reference in New Issue
Block a user