Merge branch 'staging' of github.com:FreeCodeCamp/freecodecamp into staging
This commit is contained in:
@ -47,7 +47,7 @@ export default function({ models }) {
|
||||
modified
|
||||
});
|
||||
}
|
||||
if (identity.userId !== userId) {
|
||||
if (identity.userId.toString() !== userId.toString()) {
|
||||
return Observable.throw(
|
||||
new Error('An account is already linked to that profile')
|
||||
);
|
||||
|
@ -137,7 +137,9 @@ module.exports = function(app) {
|
||||
// unless the next block is undefined, which means no next block
|
||||
let nextChallengeName = firstChallenge;
|
||||
|
||||
const challengeId = req.user.currentChallenge.challengeId;
|
||||
const challengeId = req.user.currentChallenge ?
|
||||
req.user.currentChallenge.challengeId :
|
||||
'bd7123c8c441eddfaeb5bdef';
|
||||
// find challenge
|
||||
return challenge$
|
||||
.map(challenge => challenge.toJSON())
|
||||
@ -320,7 +322,7 @@ module.exports = function(app) {
|
||||
|
||||
var challengeData = {
|
||||
id: challengeId,
|
||||
name: req.body.challengeInfo.challengeName,
|
||||
name: req.body.challengeInfo.challengeName || '',
|
||||
completedDate: Math.round(+new Date()),
|
||||
solution: req.body.challengeInfo.solution,
|
||||
challengeType: 5
|
||||
@ -399,7 +401,7 @@ module.exports = function(app) {
|
||||
{
|
||||
id: id || challengeId,
|
||||
completedDate: completedDate,
|
||||
name: name || challengeName,
|
||||
name: name || challengeName || '',
|
||||
solution: null,
|
||||
githubLink: null,
|
||||
verified: true
|
||||
@ -446,7 +448,7 @@ module.exports = function(app) {
|
||||
|
||||
var challengeData = {
|
||||
id: challengeId,
|
||||
name: req.body.challengeInfo.challengeName,
|
||||
name: req.body.challengeInfo.challengeName || '',
|
||||
completedDate: completedDate,
|
||||
solution: solutionLink,
|
||||
githubLink: githubLink,
|
||||
|
@ -18,6 +18,7 @@ var time48Hours = 172800000;
|
||||
var unDasherize = utils.unDasherize;
|
||||
var dasherize = utils.dasherize;
|
||||
var getURLTitle = utils.getURLTitle;
|
||||
var ifNoUser401 = require('../utils/middleware').ifNoUser401;
|
||||
|
||||
function hotRank(timeValue, rank) {
|
||||
/*
|
||||
@ -63,12 +64,12 @@ module.exports = function(app) {
|
||||
router.get('/stories/hotStories', hotJSON);
|
||||
router.get('/stories/submit', submitNew);
|
||||
router.get('/stories/submit/new-story', preSubmit);
|
||||
router.post('/stories/preliminary', newStory);
|
||||
router.post('/stories/', storySubmission);
|
||||
router.post('/stories/preliminary', ifNoUser401, newStory);
|
||||
router.post('/stories/', ifNoUser401, storySubmission);
|
||||
router.get('/news/', hot);
|
||||
router.post('/stories/search', getStories);
|
||||
router.get('/news/:storyName', returnIndividualStory);
|
||||
router.post('/stories/upvote/', upvote);
|
||||
router.post('/stories/upvote/', ifNoUser401, upvote);
|
||||
router.get('/stories/:storyName', redirectToNews);
|
||||
|
||||
app.use(router);
|
||||
@ -107,8 +108,12 @@ module.exports = function(app) {
|
||||
});
|
||||
}
|
||||
|
||||
function preSubmit(req, res) {
|
||||
function preSubmit(req, res, next) {
|
||||
var data = req.query;
|
||||
if (typeof data.url !== 'string') {
|
||||
req.flash('errors', { msg: 'No URL supplied with story' });
|
||||
return next(new TypeError('No URL supplied with story'));
|
||||
}
|
||||
var cleanedData = cleanData(data.url);
|
||||
|
||||
if (data.url.replace(/&/g, '&') !== cleanedData) {
|
||||
|
@ -156,7 +156,7 @@ module.exports = function(app) {
|
||||
});
|
||||
|
||||
const bonfires = user.completedChallenges.filter(function(obj) {
|
||||
return obj.challengeType === 5 && obj.name.match(/Bonfire/g);
|
||||
return obj.challengeType === 5 && (obj.name || '').match(/Bonfire/g);
|
||||
});
|
||||
|
||||
res.render('account/show', {
|
||||
|
@ -3,7 +3,7 @@ var secrets = require('../config/secrets');
|
||||
module.exports = {
|
||||
db: {
|
||||
connector: 'mongodb',
|
||||
connectionTimeout: 5000,
|
||||
connectionTimeout: 10000,
|
||||
url: secrets.db
|
||||
},
|
||||
mail: {
|
||||
|
@ -1,10 +1,31 @@
|
||||
const pathsOfNoReturn = [
|
||||
'link',
|
||||
'bower_components',
|
||||
'auth',
|
||||
'login',
|
||||
'logout',
|
||||
'signin',
|
||||
'signup',
|
||||
'fonts',
|
||||
'favicon',
|
||||
'js',
|
||||
'css'
|
||||
];
|
||||
|
||||
const pathsOfNoReturnRegex = new RegExp(pathsOfNoReturn.join('|'), 'i');
|
||||
|
||||
export default function addReturnToUrl() {
|
||||
return function(req, res, next) {
|
||||
// Remember original destination before login.
|
||||
var path = req.path.split('/')[1];
|
||||
if (/auth|login|logout|signin|signup|fonts|favicon/i.test(path)) {
|
||||
|
||||
if (req.method !== 'GET') {
|
||||
return next();
|
||||
} else if (/\/stories\/\w+/i.test(req.path)) {
|
||||
}
|
||||
if (pathsOfNoReturnRegex.test(path)) {
|
||||
return next();
|
||||
}
|
||||
if (/\/stories\/\w+/i.test(req.path)) {
|
||||
return next();
|
||||
}
|
||||
req.session.returnTo = req.path;
|
||||
|
@ -51,3 +51,10 @@ exports.ifNoUserSend = function ifNoUserSend(sendThis) {
|
||||
return res.status(200).send(sendThis);
|
||||
};
|
||||
};
|
||||
|
||||
exports.ifNoUser401 = function ifNoUser401(req, res, next) {
|
||||
if (req.user) {
|
||||
return next();
|
||||
}
|
||||
return res.status(401).end();
|
||||
};
|
||||
|
@ -2,7 +2,7 @@ extends ../layout
|
||||
block content
|
||||
script.
|
||||
var challengeName = 'Account View'
|
||||
.panel.panel-info(ng-controller="profileValidationController")
|
||||
.panel.panel-info
|
||||
.panel-heading.text-center Manage your account here
|
||||
.panel-body
|
||||
.row
|
||||
|
@ -1,5 +1,7 @@
|
||||
extends ../layout
|
||||
block content
|
||||
.bg-danger.default-border-radius
|
||||
p We are running emergency server maintenance. Your account and challenge completion will not be saved until this message goes away. Sorry about the inconvenience and thank you for your understanding.
|
||||
.panel.panel-info
|
||||
.panel-heading.text-center
|
||||
h1 Challenge Map
|
||||
|
@ -1,5 +1,7 @@
|
||||
extends layout
|
||||
block content
|
||||
.bg-danger.default-border-radius
|
||||
p We are running emergency server maintenance. Your account and challenge completion will not be saved until this message goes away. Sorry about the inconvenience and thank you for your understanding.
|
||||
.jumbotron
|
||||
.text-center
|
||||
h1.hug-top Code with Us
|
||||
|
@ -1,5 +1,7 @@
|
||||
extends ../layout
|
||||
block content
|
||||
.bg-danger.default-border-radius
|
||||
p We are running emergency server maintenance. Your account and challenge completion will not be saved until this message goes away. Sorry about the inconvenience and thank you for your understanding.
|
||||
.jumbotron
|
||||
h2.text-center Scroll down and follow along with this 8-minute guide.
|
||||
br
|
||||
|
Reference in New Issue
Block a user