mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-10-24 12:13:31 +08:00
feat(auth): Authorise 'external' requests through JWT (#17224)
This commit is contained in:
committed by
mrugesh mohapatra
parent
3397fbbf60
commit
dfda68fb58
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user