feat(auth): Authorise 'external' requests through JWT (#17224)

This commit is contained in:
Stuart Taylor
2018-05-23 21:10:56 +01:00
committed by mrugesh mohapatra
parent 3397fbbf60
commit dfda68fb58
10 changed files with 132 additions and 8 deletions

View File

@@ -20,7 +20,7 @@ function buildUserUpdate(
timezone
) {
let finalChallenge;
const updateData = { $set: {}, $push: {} };
const updateData = { $push: {} };
const { timezone: userTimezone, completedChallenges = [] } = user;
const oldChallenge = _.find(
@@ -127,13 +127,12 @@ export default function(app) {
router.get('/map', redirectToLearn);
app.use(api);
app.use('/external', api);
app.use(router);
function modernChallengeCompleted(req, res, next) {
const type = accepts(req).type('html', 'json', 'text');
req.checkBody('id', 'id must be an ObjectId').isMongoId();
req.checkBody('files', 'files must be an object with polyvinyls for keys')
.isFiles();
const errors = req.validationErrors(true);
if (errors) {