Files
freeCodeCamp/server/middlewares/privacy-terms-notice.js

23 lines
528 B
JavaScript
Raw Normal View History

2018-05-27 17:29:04 +05:30
const ALLOWED_METHODS = ['GET'];
const EXCLUDED_PATHS = [
'/api/flyers/findOne',
'/signout',
'/accept-privacy-terms'
];
export default function privacyTermsNotAcceptedNotice() {
return function(req, res, next) {
if (
ALLOWED_METHODS.indexOf(req.method) !== -1 &&
EXCLUDED_PATHS.indexOf(req.path) === -1
) {
const { user } = req;
if (user && user.acceptedPrivacyTerms !== true) {
res.redirect('/accept-privacy-terms');
return next;
}
}
return next();
};
}