chore: return 404 for update-my-current-challenge (#46042)

This commit is contained in:
Oliver Eyton-Williams
2022-05-18 15:39:52 +02:00
committed by GitHub
parent aaca146d2b
commit 21709a11cb
5 changed files with 56 additions and 40 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ import {
} from '../../../../config/certification-settings';
import { reportError } from '../middlewares/sentry-error-handler.js';
import { deprecatedEndpoint } from '../utils/deprecatedEndpoint';
import { deprecatedEndpoint } from '../utils/disabled-endpoints';
import { getChallenges } from '../utils/get-curriculum';
import { ifNoUser401 } from '../utils/middleware';
import { observeQuery } from '../utils/rx';
+1 -1
View File
@@ -1,5 +1,5 @@
import { getRedirectParams } from '../utils/redirection';
import { deprecatedEndpoint } from '../utils/deprecatedEndpoint';
import { deprecatedEndpoint } from '../utils/disabled-endpoints';
module.exports = function (app) {
const router = app.loopback.Router();
+37 -30
View File
@@ -5,7 +5,10 @@ import isURL from 'validator/lib/isURL';
import { isValidUsername } from '../../../../utils/validate';
import { alertTypes } from '../../common/utils/flash.js';
import { deprecatedEndpoint } from '../utils/deprecatedEndpoint';
import {
deprecatedEndpoint,
temporarilyDisabledEndpoint
} from '../utils/disabled-endpoints';
import { ifNoUser401, createValidatorErrorHandler } from '../utils/middleware';
const log = debug('fcc:boot:settings');
@@ -18,13 +21,15 @@ export default function settingsController(app) {
api.put('/update-privacy-terms', ifNoUser401, updatePrivacyTerms);
api.post('/refetch-user-completed-challenges', deprecatedEndpoint);
api.post(
'/update-my-current-challenge',
ifNoUser401,
updateMyCurrentChallengeValidators,
createValidatorErrorHandler(alertTypes.danger),
updateMyCurrentChallenge
);
// Re-enable once we can handle the traffic
// api.post(
// '/update-my-current-challenge',
// ifNoUser401,
// updateMyCurrentChallengeValidators,
// createValidatorErrorHandler(alertTypes.danger),
// updateMyCurrentChallenge
// );
api.post('/update-my-current-challenge', temporarilyDisabledEndpoint);
api.put('/update-my-portfolio', ifNoUser401, updateMyPortfolio);
api.put('/update-my-theme', ifNoUser401, updateMyTheme);
api.put('/update-my-about', ifNoUser401, updateMyAbout);
@@ -78,29 +83,31 @@ function updateMyEmail(req, res, next) {
.subscribe(message => res.json({ message }), next);
}
const updateMyCurrentChallengeValidators = [
check('currentChallengeId')
.isMongoId()
.withMessage('currentChallengeId is not a valid challenge ID')
];
// Re-enable once we can handle the traffic
// const updateMyCurrentChallengeValidators = [
// check('currentChallengeId')
// .isMongoId()
// .withMessage('currentChallengeId is not a valid challenge ID')
// ];
function updateMyCurrentChallenge(req, res, next) {
const {
user,
body: { currentChallengeId }
} = req;
return user.updateAttribute(
'currentChallengeId',
currentChallengeId,
(err, updatedUser) => {
if (err) {
return next(err);
}
const { currentChallengeId } = updatedUser;
return res.status(200).json(currentChallengeId);
}
);
}
// Re-enable once we can handle the traffic
// function updateMyCurrentChallenge(req, res, next) {
// const {
// user,
// body: { currentChallengeId }
// } = req;
// return user.updateAttribute(
// 'currentChallengeId',
// currentChallengeId,
// (err, updatedUser) => {
// if (err) {
// return next(err);
// }
// const { currentChallengeId } = updatedUser;
// return res.status(200).json(currentChallengeId);
// }
// );
// }
function updateMyPortfolio(...args) {
const portfolioKeys = ['id', 'title', 'description', 'url', 'image'];
@@ -1,8 +0,0 @@
export function deprecatedEndpoint(_, res) {
return res.status(410).json({
message: {
type: 'info',
message: 'Please reload the app, this feature is no longer available.'
}
});
}
@@ -0,0 +1,17 @@
export function deprecatedEndpoint(_, res) {
return res.status(410).json({
message: {
type: 'info',
message: 'Please reload the app, this feature is no longer available.'
}
});
}
export function temporarilyDisabledEndpoint(_, res) {
return res.status(404).json({
message: {
type: 'info',
message: 'Please reload the app, this feature is no longer available.'
}
});
}