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

This commit is contained in:
Stuart Taylor
2018-05-24 01:40:56 +05:30
committed by mrugesh mohapatra
parent 3397fbbf60
commit dfda68fb58
10 changed files with 132 additions and 8 deletions
+3 -1
View File
@@ -13,5 +13,7 @@ export default function bootServices(app) {
Fetchr.registerFetcher(mapUi);
Fetchr.registerFetcher(user);
app.use('/services', Fetchr.middleware());
const middleware = Fetchr.middleware();
app.use('/services', middleware);
app.use('/external/services', middleware);
}
+2 -3
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) {