Merge pull request #8412 from FreeCodeCamp/staging

Release Staging
This commit is contained in:
Berkeley Martinez
2016-05-02 21:30:56 -07:00
2 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,12 @@
import csurf from 'csurf';
export default function() {
return csurf({ cookie: true });
const protection = csurf({ cookie: true });
return function csrf(req, res, next) {
const path = req.path.split('/')[1];
if (/api/.test(path)) {
return next();
}
return protection(req, res, next);
};
}

View File

@ -2,7 +2,7 @@ export default function globalLocals() {
return function(req, res, next) {
// Make user object available in templates.
res.locals.user = req.user;
res.locals._csrf = req.csrfToken();
res.locals._csrf = req.csrfToken ? req.csrfToken() : null;
next();
};
}