chore: remove unused api endpoints (#45085)
* chore: remove /refetch-user-completed-challenges * chore: remove /update-my-theme Theme changes are handled by /update-user-flag I left 'update-my-theme' in the blocklist to allow for future use. * chore: remove /certificate/verify-can-claim-cert The client has not been using this for several weeks * feat: return 410 for redundant endpoints * chore: order endpoints
This commit is contained in:
committed by
GitHub
parent
d41433767a
commit
bc7cdf6c33
@ -1,9 +0,0 @@
|
|||||||
export const themes = {
|
|
||||||
night: 'night',
|
|
||||||
default: 'default'
|
|
||||||
};
|
|
||||||
|
|
||||||
export const invertTheme = currentTheme =>
|
|
||||||
!currentTheme || currentTheme === themes.default
|
|
||||||
? themes.night
|
|
||||||
: themes.default;
|
|
@ -52,7 +52,6 @@ export default function bootCertificate(app) {
|
|||||||
api.put('/certificate/verify', ifNoUser401, ifNoSuperBlock404, verifyCert);
|
api.put('/certificate/verify', ifNoUser401, ifNoSuperBlock404, verifyCert);
|
||||||
api.get('/certificate/showCert/:username/:certSlug', showCert);
|
api.get('/certificate/showCert/:username/:certSlug', showCert);
|
||||||
api.get('/certificate/verify-can-claim-cert', verifyCanClaimCert);
|
api.get('/certificate/verify-can-claim-cert', verifyCanClaimCert);
|
||||||
|
|
||||||
app.use(api);
|
app.use(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import isURL from 'validator/lib/isURL';
|
|||||||
|
|
||||||
import { isValidUsername } from '../../../../utils/validate';
|
import { isValidUsername } from '../../../../utils/validate';
|
||||||
import { alertTypes } from '../../common/utils/flash.js';
|
import { alertTypes } from '../../common/utils/flash.js';
|
||||||
import { themes } from '../../common/utils/themes.js';
|
|
||||||
import { ifNoUser401, createValidatorErrorHandler } from '../utils/middleware';
|
import { ifNoUser401, createValidatorErrorHandler } from '../utils/middleware';
|
||||||
|
|
||||||
const log = debug('fcc:boot:settings');
|
const log = debug('fcc:boot:settings');
|
||||||
@ -16,11 +15,7 @@ export default function settingsController(app) {
|
|||||||
|
|
||||||
api.put('/update-privacy-terms', ifNoUser401, updatePrivacyTerms);
|
api.put('/update-privacy-terms', ifNoUser401, updatePrivacyTerms);
|
||||||
|
|
||||||
api.post(
|
api.post('/refetch-user-completed-challenges', gone);
|
||||||
'/refetch-user-completed-challenges',
|
|
||||||
ifNoUser401,
|
|
||||||
refetchCompletedChallenges
|
|
||||||
);
|
|
||||||
api.post(
|
api.post(
|
||||||
'/update-my-current-challenge',
|
'/update-my-current-challenge',
|
||||||
ifNoUser401,
|
ifNoUser401,
|
||||||
@ -29,13 +24,7 @@ export default function settingsController(app) {
|
|||||||
updateMyCurrentChallenge
|
updateMyCurrentChallenge
|
||||||
);
|
);
|
||||||
api.post('/update-my-portfolio', ifNoUser401, updateMyPortfolio);
|
api.post('/update-my-portfolio', ifNoUser401, updateMyPortfolio);
|
||||||
api.post(
|
api.post('/update-my-theme', gone);
|
||||||
'/update-my-theme',
|
|
||||||
ifNoUser401,
|
|
||||||
updateMyThemeValidators,
|
|
||||||
createValidatorErrorHandler(alertTypes.danger),
|
|
||||||
updateMyTheme
|
|
||||||
);
|
|
||||||
api.put('/update-my-about', ifNoUser401, updateMyAbout);
|
api.put('/update-my-about', ifNoUser401, updateMyAbout);
|
||||||
api.put(
|
api.put(
|
||||||
'/update-my-email',
|
'/update-my-email',
|
||||||
@ -61,6 +50,15 @@ const standardSuccessMessage = {
|
|||||||
message: 'flash.updated-preferences'
|
message: 'flash.updated-preferences'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function gone(_, res) {
|
||||||
|
return res.status(410).json({
|
||||||
|
message: {
|
||||||
|
type: 'info',
|
||||||
|
message: 'Please reload the app, this feature is no longer available.'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const createStandardHandler = (req, res, next) => err => {
|
const createStandardHandler = (req, res, next) => err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.status(500).json(standardErrorMessage);
|
res.status(500).json(standardErrorMessage);
|
||||||
@ -69,13 +67,6 @@ const createStandardHandler = (req, res, next) => err => {
|
|||||||
return res.status(200).json(standardSuccessMessage);
|
return res.status(200).json(standardSuccessMessage);
|
||||||
};
|
};
|
||||||
|
|
||||||
function refetchCompletedChallenges(req, res, next) {
|
|
||||||
const { user } = req;
|
|
||||||
return user
|
|
||||||
.requestCompletedChallenges()
|
|
||||||
.subscribe(completedChallenges => res.json({ completedChallenges }), next);
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateMyEmailValidators = [
|
const updateMyEmailValidators = [
|
||||||
check('email').isEmail().withMessage('Email format is invalid.')
|
check('email').isEmail().withMessage('Email format is invalid.')
|
||||||
];
|
];
|
||||||
@ -114,25 +105,6 @@ function updateMyCurrentChallenge(req, res, next) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateMyThemeValidators = [
|
|
||||||
check('theme').isIn(Object.keys(themes)).withMessage('Theme is invalid.')
|
|
||||||
];
|
|
||||||
|
|
||||||
function updateMyTheme(req, res, next) {
|
|
||||||
const {
|
|
||||||
body: { theme }
|
|
||||||
} = req;
|
|
||||||
if (req.user.theme === theme) {
|
|
||||||
return res.sendFlash(alertTypes.info, 'Theme already set');
|
|
||||||
}
|
|
||||||
return req.user
|
|
||||||
.updateTheme(theme)
|
|
||||||
.then(
|
|
||||||
() => res.sendFlash(alertTypes.info, 'Your theme has been updated!'),
|
|
||||||
next
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateMyPortfolio(req, res, next) {
|
function updateMyPortfolio(req, res, next) {
|
||||||
const {
|
const {
|
||||||
user,
|
user,
|
||||||
|
Reference in New Issue
Block a user